mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge from vscode e3b9b8eefc062d68ba8a4b6a817162d132f3b533 (#6932)
* Merge from vscode e3b9b8eefc062d68ba8a4b6a817162d132f3b533 * skip failing test * add comment
This commit is contained in:
@@ -40,8 +40,10 @@ import { ServiceCollection } from 'vs/platform/instantiation/common/serviceColle
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
import { defaultInsertColor, defaultRemoveColor, diffBorder, diffInserted, diffInsertedOutline, diffRemoved, diffRemovedOutline, scrollbarShadow } from 'vs/platform/theme/common/colorRegistry';
|
||||
import { ITheme, IThemeService, getThemeTypeSelector, registerThemingParticipant } from 'vs/platform/theme/common/themeService';
|
||||
// {{SQL CARBON EDIT}}
|
||||
import { reverseLineChanges } from 'sql/editor/browser/diffEditorHelper';
|
||||
import { reverseLineChanges } from 'sql/editor/browser/diffEditorHelper'; // {{SQL CARBON EDIT}}
|
||||
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { IDiffLinesChange, InlineDiffMargin } from 'vs/editor/browser/widget/inlineDiffMargin';
|
||||
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
|
||||
|
||||
interface IEditorDiffDecorations {
|
||||
decorations: IModelDeltaDecoration[];
|
||||
@@ -49,7 +51,7 @@ interface IEditorDiffDecorations {
|
||||
}
|
||||
|
||||
interface IEditorDiffDecorationsWithZones extends IEditorDiffDecorations {
|
||||
zones: editorBrowser.IViewZone[];
|
||||
zones: IMyViewZone[];
|
||||
}
|
||||
|
||||
interface IEditorsDiffDecorationsWithZones {
|
||||
@@ -58,8 +60,8 @@ interface IEditorsDiffDecorationsWithZones {
|
||||
}
|
||||
|
||||
interface IEditorsZones {
|
||||
original: editorBrowser.IViewZone[];
|
||||
modified: editorBrowser.IViewZone[];
|
||||
original: IMyViewZone[];
|
||||
modified: IMyViewZone[];
|
||||
}
|
||||
|
||||
interface IDiffEditorWidgetStyle {
|
||||
@@ -73,11 +75,16 @@ interface IDiffEditorWidgetStyle {
|
||||
|
||||
class VisualEditorState {
|
||||
private _zones: string[];
|
||||
private inlineDiffMargins: InlineDiffMargin[];
|
||||
private _zonesMap: { [zoneId: string]: boolean; };
|
||||
private _decorations: string[];
|
||||
|
||||
constructor() {
|
||||
constructor(
|
||||
private _contextMenuService: IContextMenuService,
|
||||
private _clipboardService: IClipboardService
|
||||
) {
|
||||
this._zones = [];
|
||||
this.inlineDiffMargins = [];
|
||||
this._zonesMap = {};
|
||||
this._decorations = [];
|
||||
}
|
||||
@@ -111,13 +118,22 @@ class VisualEditorState {
|
||||
for (let i = 0, length = this._zones.length; i < length; i++) {
|
||||
viewChangeAccessor.removeZone(this._zones[i]);
|
||||
}
|
||||
for (let i = 0, length = this.inlineDiffMargins.length; i < length; i++) {
|
||||
this.inlineDiffMargins[i].dispose();
|
||||
}
|
||||
this._zones = [];
|
||||
this._zonesMap = {};
|
||||
this.inlineDiffMargins = [];
|
||||
for (let i = 0, length = newDecorations.zones.length; i < length; i++) {
|
||||
newDecorations.zones[i].suppressMouseDown = true;
|
||||
let zoneId = viewChangeAccessor.addZone(newDecorations.zones[i]);
|
||||
const viewZone = <editorBrowser.IViewZone>newDecorations.zones[i];
|
||||
viewZone.suppressMouseDown = false;
|
||||
let zoneId = viewChangeAccessor.addZone(viewZone);
|
||||
this._zones.push(zoneId);
|
||||
this._zonesMap[String(zoneId)] = true;
|
||||
|
||||
if (newDecorations.zones[i].diff && viewZone.marginDomNode) {
|
||||
this.inlineDiffMargins.push(new InlineDiffMargin(viewZone.marginDomNode, editor, newDecorations.zones[i].diff!, this._contextMenuService, this._clipboardService));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -207,7 +223,9 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
@IInstantiationService instantiationService: IInstantiationService,
|
||||
@ICodeEditorService codeEditorService: ICodeEditorService,
|
||||
@IThemeService themeService: IThemeService,
|
||||
@INotificationService notificationService: INotificationService
|
||||
@INotificationService notificationService: INotificationService,
|
||||
@IContextMenuService contextMenuService: IContextMenuService,
|
||||
@IClipboardService clipboardService: IClipboardService
|
||||
) {
|
||||
super();
|
||||
|
||||
@@ -289,8 +307,8 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
this._currentlyChangingViewZones = false;
|
||||
this._diffComputationToken = 0;
|
||||
|
||||
this._originalEditorState = new VisualEditorState();
|
||||
this._modifiedEditorState = new VisualEditorState();
|
||||
this._originalEditorState = new VisualEditorState(contextMenuService, clipboardService);
|
||||
this._modifiedEditorState = new VisualEditorState(contextMenuService, clipboardService);
|
||||
|
||||
this._isVisible = true;
|
||||
this._isHandlingScrollEvent = false;
|
||||
@@ -1278,6 +1296,7 @@ interface IMyViewZone {
|
||||
minWidthInPx?: number;
|
||||
domNode: HTMLElement | null;
|
||||
marginDomNode?: HTMLElement | null;
|
||||
diff?: IDiffLinesChange;
|
||||
}
|
||||
|
||||
class ForeignViewZonesIterator {
|
||||
@@ -1489,12 +1508,12 @@ abstract class ViewZonesComputer {
|
||||
};
|
||||
}
|
||||
|
||||
private static _ensureDomNodes(zones: IMyViewZone[]): editorBrowser.IViewZone[] {
|
||||
private static _ensureDomNodes(zones: IMyViewZone[]): IMyViewZone[] {
|
||||
return zones.map((z) => {
|
||||
if (!z.domNode) {
|
||||
z.domNode = createFakeLinesDiv();
|
||||
}
|
||||
return <editorBrowser.IViewZone>z;
|
||||
return z;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1997,8 +2016,10 @@ class InlineViewZonesComputer extends ViewZonesComputer {
|
||||
let lineHeight = this.modifiedEditorConfiguration.lineHeight;
|
||||
const typicalHalfwidthCharacterWidth = this.modifiedEditorConfiguration.fontInfo.typicalHalfwidthCharacterWidth;
|
||||
let maxCharsPerLine = 0;
|
||||
const originalContent: string[] = [];
|
||||
for (let lineNumber = lineChange.originalStartLineNumber; lineNumber <= lineChange.originalEndLineNumber; lineNumber++) {
|
||||
maxCharsPerLine = Math.max(maxCharsPerLine, this._renderOriginalLine(lineNumber - lineChange.originalStartLineNumber, this.originalModel, this.modifiedEditorConfiguration, this.modifiedEditorTabSize, lineNumber, decorations, sb));
|
||||
originalContent.push(this.originalModel.getLineContent(lineNumber));
|
||||
|
||||
if (this.renderIndicators) {
|
||||
let index = lineNumber - lineChange.originalStartLineNumber;
|
||||
@@ -2025,7 +2046,14 @@ class InlineViewZonesComputer extends ViewZonesComputer {
|
||||
heightInLines: lineChangeOriginalLength,
|
||||
minWidthInPx: (maxCharsPerLine * typicalHalfwidthCharacterWidth),
|
||||
domNode: domNode,
|
||||
marginDomNode: marginDomNode
|
||||
marginDomNode: marginDomNode,
|
||||
diff: {
|
||||
originalStartLineNumber: lineChange.originalStartLineNumber,
|
||||
originalEndLineNumber: lineChange.originalEndLineNumber,
|
||||
modifiedStartLineNumber: lineChange.modifiedStartLineNumber,
|
||||
modifiedEndLineNumber: lineChange.modifiedEndLineNumber,
|
||||
originalContent: originalContent
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility';
|
||||
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
|
||||
|
||||
export class EmbeddedCodeEditorWidget extends CodeEditorWidget {
|
||||
|
||||
@@ -74,9 +76,11 @@ export class EmbeddedDiffEditorWidget extends DiffEditorWidget {
|
||||
@IInstantiationService instantiationService: IInstantiationService,
|
||||
@ICodeEditorService codeEditorService: ICodeEditorService,
|
||||
@IThemeService themeService: IThemeService,
|
||||
@INotificationService notificationService: INotificationService
|
||||
@INotificationService notificationService: INotificationService,
|
||||
@IContextMenuService contextMenuService: IContextMenuService,
|
||||
@IClipboardService clipboardService: IClipboardService
|
||||
) {
|
||||
super(domElement, parentEditor.getRawConfiguration(), editorWorkerService, contextKeyService, instantiationService, codeEditorService, themeService, notificationService);
|
||||
super(domElement, parentEditor.getRawConfiguration(), editorWorkerService, contextKeyService, instantiationService, codeEditorService, themeService, notificationService, contextMenuService, clipboardService);
|
||||
|
||||
this._parentEditor = parentEditor;
|
||||
this._overwriteOptions = options;
|
||||
|
||||
139
src/vs/editor/browser/widget/inlineDiffMargin.ts
Normal file
139
src/vs/editor/browser/widget/inlineDiffMargin.ts
Normal file
@@ -0,0 +1,139 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as nls from 'vs/nls';
|
||||
import * as dom from 'vs/base/browser/dom';
|
||||
import { Action } from 'vs/base/common/actions';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget';
|
||||
|
||||
export interface IDiffLinesChange {
|
||||
readonly originalStartLineNumber: number;
|
||||
readonly originalEndLineNumber: number;
|
||||
readonly modifiedStartLineNumber: number;
|
||||
readonly modifiedEndLineNumber: number;
|
||||
readonly originalContent: string[];
|
||||
}
|
||||
|
||||
export class InlineDiffMargin extends Disposable {
|
||||
private readonly _lightBulb: HTMLElement;
|
||||
|
||||
constructor(
|
||||
marginDomNode: HTMLElement,
|
||||
public editor: CodeEditorWidget,
|
||||
public diff: IDiffLinesChange,
|
||||
private _contextMenuService: IContextMenuService,
|
||||
private _clipboardService: IClipboardService
|
||||
) {
|
||||
super();
|
||||
|
||||
// make sure the diff margin shows above overlay.
|
||||
marginDomNode.style.zIndex = '10';
|
||||
|
||||
this._lightBulb = document.createElement('div');
|
||||
this._lightBulb.className = 'lightbulb-glyph';
|
||||
this._lightBulb.style.position = 'absolute';
|
||||
const lineHeight = editor.getConfiguration().lineHeight;
|
||||
const lineFeed = editor.getModel()!.getEOL();
|
||||
this._lightBulb.style.right = '0px';
|
||||
this._lightBulb.style.visibility = 'hidden';
|
||||
this._lightBulb.style.height = `${lineHeight}px`;
|
||||
marginDomNode.appendChild(this._lightBulb);
|
||||
|
||||
const actions = [
|
||||
new Action(
|
||||
'diff.clipboard.copyDeletedContent',
|
||||
nls.localize('diff.clipboard.copyDeletedContent.label', "Copy deleted lines content to clipboard"),
|
||||
undefined,
|
||||
true,
|
||||
async () => {
|
||||
await this._clipboardService.writeText(diff.originalContent.join(lineFeed) + lineFeed);
|
||||
}
|
||||
)
|
||||
];
|
||||
|
||||
let currentLineNumberOffset = 0;
|
||||
|
||||
const copyLineAction = new Action(
|
||||
'diff.clipboard.copyDeletedLineContent',
|
||||
nls.localize('diff.clipboard.copyDeletedLineContent.label', "Copy deleted line {0} content to clipboard", diff.originalStartLineNumber),
|
||||
undefined,
|
||||
true,
|
||||
async () => {
|
||||
await this._clipboardService.writeText(diff.originalContent[currentLineNumberOffset]);
|
||||
}
|
||||
);
|
||||
|
||||
actions.push(copyLineAction);
|
||||
|
||||
const readOnly = editor.getConfiguration().readOnly;
|
||||
if (!readOnly) {
|
||||
actions.push(new Action('diff.inline.revertChange', nls.localize('diff.inline.revertChange.label', "Revert this change"), undefined, true, async () => {
|
||||
if (diff.modifiedEndLineNumber === 0) {
|
||||
// deletion only
|
||||
const column = editor.getModel()!.getLineMaxColumn(diff.modifiedStartLineNumber);
|
||||
editor.executeEdits('diffEditor', [
|
||||
{
|
||||
range: new Range(diff.modifiedStartLineNumber, column, diff.modifiedStartLineNumber, column),
|
||||
text: lineFeed + diff.originalContent.join(lineFeed)
|
||||
}
|
||||
]);
|
||||
} else {
|
||||
const column = editor.getModel()!.getLineMaxColumn(diff.modifiedEndLineNumber);
|
||||
editor.executeEdits('diffEditor', [
|
||||
{
|
||||
range: new Range(diff.modifiedStartLineNumber, 1, diff.modifiedEndLineNumber, column),
|
||||
text: diff.originalContent.join(lineFeed)
|
||||
}
|
||||
]);
|
||||
}
|
||||
|
||||
}));
|
||||
}
|
||||
|
||||
this._register(dom.addStandardDisposableListener(marginDomNode, 'mouseenter', e => {
|
||||
this._lightBulb.style.visibility = 'visible';
|
||||
currentLineNumberOffset = this._updateLightBulbPosition(marginDomNode, e.y, lineHeight);
|
||||
}));
|
||||
|
||||
this._register(dom.addStandardDisposableListener(marginDomNode, 'mouseleave', e => {
|
||||
this._lightBulb.style.visibility = 'hidden';
|
||||
}));
|
||||
|
||||
this._register(dom.addStandardDisposableListener(marginDomNode, 'mousemove', e => {
|
||||
currentLineNumberOffset = this._updateLightBulbPosition(marginDomNode, e.y, lineHeight);
|
||||
}));
|
||||
|
||||
this._register(dom.addStandardDisposableListener(this._lightBulb, 'mousedown', e => {
|
||||
const { top, height } = dom.getDomNodePagePosition(this._lightBulb);
|
||||
let pad = Math.floor(lineHeight / 3) + lineHeight;
|
||||
this._contextMenuService.showContextMenu({
|
||||
getAnchor: () => {
|
||||
return {
|
||||
x: e.posx,
|
||||
y: top + height + pad
|
||||
};
|
||||
},
|
||||
getActions: () => {
|
||||
copyLineAction.label = nls.localize('diff.clipboard.copyDeletedLineContent.label', "Copy deleted line {0} content to clipboard", diff.originalStartLineNumber + currentLineNumberOffset);
|
||||
return actions;
|
||||
},
|
||||
autoSelectFirstItem: true
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
private _updateLightBulbPosition(marginDomNode: HTMLElement, y: number, lineHeight: number): number {
|
||||
const { top } = dom.getDomNodePagePosition(marginDomNode);
|
||||
const offset = y - top;
|
||||
const lineNumberOffset = Math.floor(offset / lineHeight);
|
||||
const newTop = lineNumberOffset * lineHeight;
|
||||
this._lightBulb.style.top = `${newTop}px`;
|
||||
return lineNumberOffset;
|
||||
}
|
||||
}
|
||||
@@ -2191,7 +2191,7 @@ export class InternalEditorOptionsFactory {
|
||||
selectOnLineNumbers: opts.viewInfo.selectOnLineNumbers,
|
||||
glyphMargin: opts.viewInfo.glyphMargin,
|
||||
revealHorizontalRightPadding: opts.viewInfo.revealHorizontalRightPadding,
|
||||
roundedSelection: (accessibilityIsOn ? false : opts.viewInfo.roundedSelection), // DISABLED WHEN SCREEN READER IS ATTACHED
|
||||
roundedSelection: opts.viewInfo.roundedSelection,
|
||||
overviewRulerLanes: opts.viewInfo.overviewRulerLanes,
|
||||
overviewRulerBorder: opts.viewInfo.overviewRulerBorder,
|
||||
cursorBlinking: opts.viewInfo.cursorBlinking,
|
||||
@@ -2204,15 +2204,15 @@ export class InternalEditorOptionsFactory {
|
||||
scrollBeyondLastColumn: opts.viewInfo.scrollBeyondLastColumn,
|
||||
smoothScrolling: opts.viewInfo.smoothScrolling,
|
||||
stopRenderingLineAfter: opts.viewInfo.stopRenderingLineAfter,
|
||||
renderWhitespace: (accessibilityIsOn ? 'none' : opts.viewInfo.renderWhitespace), // DISABLED WHEN SCREEN READER IS ATTACHED
|
||||
renderControlCharacters: (accessibilityIsOn ? false : opts.viewInfo.renderControlCharacters), // DISABLED WHEN SCREEN READER IS ATTACHED
|
||||
renderWhitespace: opts.viewInfo.renderWhitespace,
|
||||
renderControlCharacters: opts.viewInfo.renderControlCharacters,
|
||||
fontLigatures: opts.viewInfo.fontLigatures,
|
||||
renderIndentGuides: (accessibilityIsOn ? false : opts.viewInfo.renderIndentGuides), // DISABLED WHEN SCREEN READER IS ATTACHED
|
||||
renderIndentGuides: opts.viewInfo.renderIndentGuides,
|
||||
highlightActiveIndentGuide: opts.viewInfo.highlightActiveIndentGuide,
|
||||
renderLineHighlight: opts.viewInfo.renderLineHighlight,
|
||||
scrollbar: opts.viewInfo.scrollbar,
|
||||
minimap: {
|
||||
enabled: (accessibilityIsOn ? false : opts.viewInfo.minimap.enabled), // DISABLED WHEN SCREEN READER IS ATTACHED
|
||||
enabled: opts.viewInfo.minimap.enabled,
|
||||
side: opts.viewInfo.minimap.side,
|
||||
renderCharacters: opts.viewInfo.minimap.renderCharacters,
|
||||
showSlider: opts.viewInfo.minimap.showSlider,
|
||||
@@ -2224,7 +2224,7 @@ export class InternalEditorOptionsFactory {
|
||||
contribInfo: {
|
||||
selectionClipboard: opts.contribInfo.selectionClipboard,
|
||||
hover: opts.contribInfo.hover,
|
||||
links: (accessibilityIsOn ? false : opts.contribInfo.links), // DISABLED WHEN SCREEN READER IS ATTACHED
|
||||
links: opts.contribInfo.links,
|
||||
contextmenu: opts.contribInfo.contextmenu,
|
||||
quickSuggestions: opts.contribInfo.quickSuggestions,
|
||||
quickSuggestionsDelay: opts.contribInfo.quickSuggestionsDelay,
|
||||
@@ -2241,13 +2241,13 @@ export class InternalEditorOptionsFactory {
|
||||
tabCompletion: opts.contribInfo.tabCompletion,
|
||||
suggest: opts.contribInfo.suggest,
|
||||
gotoLocation: opts.contribInfo.gotoLocation,
|
||||
selectionHighlight: (accessibilityIsOn ? false : opts.contribInfo.selectionHighlight), // DISABLED WHEN SCREEN READER IS ATTACHED
|
||||
occurrencesHighlight: (accessibilityIsOn ? false : opts.contribInfo.occurrencesHighlight), // DISABLED WHEN SCREEN READER IS ATTACHED
|
||||
codeLens: (accessibilityIsOn ? false : opts.contribInfo.codeLens), // DISABLED WHEN SCREEN READER IS ATTACHED
|
||||
selectionHighlight: opts.contribInfo.selectionHighlight,
|
||||
occurrencesHighlight: opts.contribInfo.occurrencesHighlight,
|
||||
codeLens: opts.contribInfo.codeLens,
|
||||
folding: (accessibilityIsOn ? false : opts.contribInfo.folding), // DISABLED WHEN SCREEN READER IS ATTACHED
|
||||
foldingStrategy: opts.contribInfo.foldingStrategy,
|
||||
showFoldingControls: opts.contribInfo.showFoldingControls,
|
||||
matchBrackets: (accessibilityIsOn ? false : opts.contribInfo.matchBrackets), // DISABLED WHEN SCREEN READER IS ATTACHED
|
||||
matchBrackets: opts.contribInfo.matchBrackets,
|
||||
find: opts.contribInfo.find,
|
||||
colorDecorators: opts.contribInfo.colorDecorators,
|
||||
lightbulbEnabled: opts.contribInfo.lightbulbEnabled,
|
||||
|
||||
@@ -367,7 +367,7 @@ export let completionKindFromString: {
|
||||
};
|
||||
})();
|
||||
|
||||
export const enum CompletionItemKindModifier {
|
||||
export const enum CompletionItemTag {
|
||||
Deprecated = 1
|
||||
}
|
||||
|
||||
@@ -404,7 +404,7 @@ export interface CompletionItem {
|
||||
* A modifier to the `kind` which affect how the item
|
||||
* is rendered, e.g. Deprecated is rendered with a strikeout
|
||||
*/
|
||||
kindModifier?: Set<CompletionItemKindModifier>;
|
||||
tags?: ReadonlyArray<CompletionItemTag>;
|
||||
/**
|
||||
* A human-readable string with additional information
|
||||
* about this item, like type or symbol information.
|
||||
@@ -867,7 +867,7 @@ export const enum SymbolKind {
|
||||
TypeParameter = 25
|
||||
}
|
||||
|
||||
export const enum SymbolKindTag {
|
||||
export const enum SymbolTag {
|
||||
Deprecated = 1,
|
||||
}
|
||||
|
||||
@@ -913,7 +913,7 @@ export interface DocumentSymbol {
|
||||
name: string;
|
||||
detail: string;
|
||||
kind: SymbolKind;
|
||||
kindTags: SymbolKindTag[];
|
||||
tags: ReadonlyArray<SymbolTag>;
|
||||
containerName?: string;
|
||||
range: IRange;
|
||||
selectionRange: IRange;
|
||||
|
||||
@@ -581,7 +581,7 @@ export enum CompletionItemKind {
|
||||
Snippet = 25
|
||||
}
|
||||
|
||||
export enum CompletionItemKindModifier {
|
||||
export enum CompletionItemTag {
|
||||
Deprecated = 1
|
||||
}
|
||||
|
||||
@@ -662,6 +662,6 @@ export enum SymbolKind {
|
||||
TypeParameter = 25
|
||||
}
|
||||
|
||||
export enum SymbolKindTag {
|
||||
export enum SymbolTag {
|
||||
Deprecated = 1
|
||||
}
|
||||
@@ -32,7 +32,7 @@ export class CodeLensContribution implements editorCommon.IEditorContribution {
|
||||
private _currentCodeLensModel: CodeLensModel | undefined;
|
||||
private _modelChangeCounter: number = 0;
|
||||
private _currentResolveCodeLensSymbolsPromise: CancelablePromise<any> | undefined;
|
||||
private _detectVisibleLenses!: RunOnceScheduler;
|
||||
private _detectVisibleLenses: RunOnceScheduler | undefined;
|
||||
|
||||
constructor(
|
||||
private readonly _editor: editorBrowser.ICodeEditor,
|
||||
@@ -121,9 +121,7 @@ export class CodeLensContribution implements editorCommon.IEditorContribution {
|
||||
}
|
||||
}
|
||||
|
||||
this._detectVisibleLenses = new RunOnceScheduler(() => {
|
||||
this._onViewportChanged();
|
||||
}, 250);
|
||||
const detectVisibleLenses = this._detectVisibleLenses = new RunOnceScheduler(() => this._onViewportChanged(), 250);
|
||||
|
||||
const scheduler = new RunOnceScheduler(() => {
|
||||
const counterValue = ++this._modelChangeCounter;
|
||||
@@ -145,12 +143,12 @@ export class CodeLensContribution implements editorCommon.IEditorContribution {
|
||||
|
||||
// render lenses
|
||||
this._renderCodeLensSymbols(result);
|
||||
this._detectVisibleLenses.schedule();
|
||||
detectVisibleLenses.schedule();
|
||||
}
|
||||
}, onUnexpectedError);
|
||||
}, 250);
|
||||
this._localToDispose.add(scheduler);
|
||||
this._localToDispose.add(this._detectVisibleLenses);
|
||||
this._localToDispose.add(detectVisibleLenses);
|
||||
this._localToDispose.add(this._editor.onDidChangeModelContent(() => {
|
||||
this._editor.changeDecorations(decorationsAccessor => {
|
||||
this._editor.changeViewZones(viewZonesAccessor => {
|
||||
@@ -179,17 +177,17 @@ export class CodeLensContribution implements editorCommon.IEditorContribution {
|
||||
});
|
||||
|
||||
// Compute new `visible` code lenses
|
||||
this._detectVisibleLenses.schedule();
|
||||
detectVisibleLenses.schedule();
|
||||
// Ask for all references again
|
||||
scheduler.schedule();
|
||||
}));
|
||||
this._localToDispose.add(this._editor.onDidScrollChange(e => {
|
||||
if (e.scrollTopChanged && this._lenses.length > 0) {
|
||||
this._detectVisibleLenses.schedule();
|
||||
detectVisibleLenses.schedule();
|
||||
}
|
||||
}));
|
||||
this._localToDispose.add(this._editor.onDidLayoutChange(() => {
|
||||
this._detectVisibleLenses.schedule();
|
||||
detectVisibleLenses.schedule();
|
||||
}));
|
||||
this._localToDispose.add(toDisposable(() => {
|
||||
if (this._editor.getModel()) {
|
||||
@@ -281,7 +279,7 @@ export class CodeLensContribution implements editorCommon.IEditorContribution {
|
||||
groupsIndex++;
|
||||
codeLensIndex++;
|
||||
} else {
|
||||
this._lenses.splice(codeLensIndex, 0, new CodeLensWidget(groups[groupsIndex], this._editor, helper, viewZoneAccessor, () => this._detectVisibleLenses.schedule()));
|
||||
this._lenses.splice(codeLensIndex, 0, new CodeLensWidget(groups[groupsIndex], this._editor, helper, viewZoneAccessor, () => this._detectVisibleLenses && this._detectVisibleLenses.schedule()));
|
||||
codeLensIndex++;
|
||||
groupsIndex++;
|
||||
}
|
||||
@@ -295,7 +293,7 @@ export class CodeLensContribution implements editorCommon.IEditorContribution {
|
||||
|
||||
// Create extra symbols
|
||||
while (groupsIndex < groups.length) {
|
||||
this._lenses.push(new CodeLensWidget(groups[groupsIndex], this._editor, helper, viewZoneAccessor, () => this._detectVisibleLenses.schedule()));
|
||||
this._lenses.push(new CodeLensWidget(groups[groupsIndex], this._editor, helper, viewZoneAccessor, () => this._detectVisibleLenses && this._detectVisibleLenses.schedule()));
|
||||
groupsIndex++;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,11 +20,6 @@
|
||||
color: var(--outline-element-color);
|
||||
}
|
||||
|
||||
.monaco-list .outline-element .deprecated {
|
||||
text-decoration: line-through;
|
||||
opacity: 0.66;
|
||||
}
|
||||
|
||||
.monaco-tree .monaco-tree-row.focused .outline-element .outline-element-detail {
|
||||
visibility: inherit;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,11 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
.monaco-workbench .monaco-icon-label.deprecated {
|
||||
text-decoration: line-through;
|
||||
opacity: 0.66;
|
||||
}
|
||||
|
||||
.monaco-workbench .symbol-icon.inline {
|
||||
background-position: left center;
|
||||
padding-left: 20px;
|
||||
|
||||
@@ -12,7 +12,7 @@ import { createMatches, FuzzyScore } from 'vs/base/common/filters';
|
||||
import 'vs/css!./media/outlineTree';
|
||||
import 'vs/css!./media/symbol-icons';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { SymbolKind, symbolKindToCssClass, SymbolKindTag } from 'vs/editor/common/modes';
|
||||
import { SymbolKind, symbolKindToCssClass, SymbolTag } from 'vs/editor/common/modes';
|
||||
import { OutlineElement, OutlineGroup, OutlineModel } from 'vs/editor/contrib/documentSymbols/outlineModel';
|
||||
import { localize } from 'vs/nls';
|
||||
import { IconLabel } from 'vs/base/browser/ui/iconLabel/iconLabel';
|
||||
@@ -127,7 +127,7 @@ export class OutlineElementRenderer implements ITreeRenderer<OutlineElement, Fuz
|
||||
// add styles for the icons
|
||||
options.extraClasses.push(`outline-element-icon ${symbolKindToCssClass(element.symbol.kind, true)}`);
|
||||
}
|
||||
if (element.symbol.kindTags.indexOf(SymbolKindTag.Deprecated) >= 0) {
|
||||
if (element.symbol.tags.indexOf(SymbolTag.Deprecated) >= 0) {
|
||||
options.extraClasses.push(`deprecated`);
|
||||
options.matches = [];
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ suite('OutlineModel', function () {
|
||||
name,
|
||||
detail: 'fake',
|
||||
kind: SymbolKind.Boolean,
|
||||
kindTags: [],
|
||||
tags: [],
|
||||
selectionRange: range,
|
||||
range: range
|
||||
};
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import * as nls from 'vs/nls';
|
||||
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
|
||||
import { dispose } from 'vs/base/common/lifecycle';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IEditorContribution } from 'vs/editor/common/editorCommon';
|
||||
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
|
||||
@@ -18,7 +18,7 @@ import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegis
|
||||
import * as modes from 'vs/editor/common/modes';
|
||||
import { TriggerContext } from 'vs/editor/contrib/parameterHints/parameterHintsModel';
|
||||
|
||||
class ParameterHintsController implements IEditorContribution {
|
||||
class ParameterHintsController extends Disposable implements IEditorContribution {
|
||||
|
||||
private static readonly ID = 'editor.controller.parameterHints';
|
||||
|
||||
@@ -30,8 +30,9 @@ class ParameterHintsController implements IEditorContribution {
|
||||
private readonly widget: ParameterHintsWidget;
|
||||
|
||||
constructor(editor: ICodeEditor, @IInstantiationService instantiationService: IInstantiationService) {
|
||||
super();
|
||||
this.editor = editor;
|
||||
this.widget = instantiationService.createInstance(ParameterHintsWidget, this.editor);
|
||||
this.widget = this._register(instantiationService.createInstance(ParameterHintsWidget, this.editor));
|
||||
}
|
||||
|
||||
getId(): string {
|
||||
@@ -53,10 +54,6 @@ class ParameterHintsController implements IEditorContribution {
|
||||
trigger(context: TriggerContext): void {
|
||||
this.widget.trigger(context);
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
dispose(this.widget);
|
||||
}
|
||||
}
|
||||
|
||||
export class TriggerParameterHintsAction extends EditorAction {
|
||||
@@ -76,7 +73,7 @@ export class TriggerParameterHintsAction extends EditorAction {
|
||||
}
|
||||
|
||||
public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
|
||||
let controller = ParameterHintsController.get(editor);
|
||||
const controller = ParameterHintsController.get(editor);
|
||||
if (controller) {
|
||||
controller.trigger({
|
||||
triggerKind: modes.SignatureHelpTriggerKind.Invoke
|
||||
|
||||
@@ -3,44 +3,41 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { illegalArgument, onUnexpectedExternalError } from 'vs/base/common/errors';
|
||||
import { illegalArgument } from 'vs/base/common/errors';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { ITextModel } from 'vs/editor/common/model';
|
||||
import { registerLanguageCommand } from 'vs/editor/browser/editorExtensions';
|
||||
import { DocumentSymbol, DocumentSymbolProviderRegistry } from 'vs/editor/common/modes';
|
||||
import { DocumentSymbol } from 'vs/editor/common/modes';
|
||||
import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { ITextModelService } from 'vs/editor/common/services/resolverService';
|
||||
import { OutlineModel, OutlineElement } from 'vs/editor/contrib/documentSymbols/outlineModel';
|
||||
import { values } from 'vs/base/common/collections';
|
||||
|
||||
export function getDocumentSymbols(model: ITextModel, flat: boolean, token: CancellationToken): Promise<DocumentSymbol[]> {
|
||||
export async function getDocumentSymbols(document: ITextModel, flat: boolean, token: CancellationToken): Promise<DocumentSymbol[]> {
|
||||
|
||||
let roots: DocumentSymbol[] = [];
|
||||
|
||||
let promises = DocumentSymbolProviderRegistry.all(model).map(support => {
|
||||
|
||||
return Promise.resolve(support.provideDocumentSymbols(model, token)).then(result => {
|
||||
if (Array.isArray(result)) {
|
||||
roots.push(...result);
|
||||
}
|
||||
}, err => {
|
||||
onUnexpectedExternalError(err);
|
||||
});
|
||||
});
|
||||
|
||||
return Promise.all(promises).then(() => {
|
||||
let flatEntries: DocumentSymbol[] = [];
|
||||
if (token.isCancellationRequested) {
|
||||
return flatEntries;
|
||||
}
|
||||
if (flat) {
|
||||
flatten(flatEntries, roots, '');
|
||||
const model = await OutlineModel.create(document, token);
|
||||
const roots: DocumentSymbol[] = [];
|
||||
for (const child of values(model.children)) {
|
||||
if (child instanceof OutlineElement) {
|
||||
roots.push(child.symbol);
|
||||
} else {
|
||||
flatEntries = roots;
|
||||
roots.push(...values(child.children).map(child => child.symbol));
|
||||
}
|
||||
flatEntries.sort(compareEntriesUsingStart);
|
||||
}
|
||||
|
||||
let flatEntries: DocumentSymbol[] = [];
|
||||
if (token.isCancellationRequested) {
|
||||
return flatEntries;
|
||||
});
|
||||
}
|
||||
if (flat) {
|
||||
flatten(flatEntries, roots, '');
|
||||
} else {
|
||||
flatEntries = roots;
|
||||
}
|
||||
|
||||
return flatEntries.sort(compareEntriesUsingStart);
|
||||
}
|
||||
|
||||
function compareEntriesUsingStart(a: DocumentSymbol, b: DocumentSymbol): number {
|
||||
@@ -51,7 +48,7 @@ function flatten(bucket: DocumentSymbol[], entries: DocumentSymbol[], overrideCo
|
||||
for (let entry of entries) {
|
||||
bucket.push({
|
||||
kind: entry.kind,
|
||||
kindTags: [],
|
||||
tags: entry.tags,
|
||||
name: entry.name,
|
||||
detail: entry.detail,
|
||||
containerName: entry.containerName || overrideContainerLabel,
|
||||
|
||||
@@ -30,7 +30,7 @@ import { MarkdownRenderer } from 'vs/editor/contrib/markdown/markdownRenderer';
|
||||
import { IModeService } from 'vs/editor/common/services/modeService';
|
||||
import { IOpenerService } from 'vs/platform/opener/common/opener';
|
||||
import { TimeoutTimer, CancelablePromise, createCancelablePromise, disposableTimeout } from 'vs/base/common/async';
|
||||
import { CompletionItemKind, completionKindToCssClass, CompletionItemKindModifier } from 'vs/editor/common/modes';
|
||||
import { CompletionItemKind, completionKindToCssClass, CompletionItemTag } from 'vs/editor/common/modes';
|
||||
import { IconLabel, IIconLabelValueOptions } from 'vs/base/browser/ui/iconLabel/iconLabel';
|
||||
import { getIconClasses } from 'vs/editor/common/services/getIconClasses';
|
||||
import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
@@ -193,7 +193,7 @@ class Renderer implements IListRenderer<CompletionItem, ISuggestionTemplateData>
|
||||
];
|
||||
}
|
||||
|
||||
if (suggestion.kindModifier && suggestion.kindModifier.has(CompletionItemKindModifier.Deprecated)) {
|
||||
if (suggestion.tags && suggestion.tags.indexOf(CompletionItemTag.Deprecated) >= 0) {
|
||||
labelOptions.extraClasses = (labelOptions.extraClasses || []).concat(['deprecated']);
|
||||
labelOptions.matches = [];
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ import { ISingleFolderWorkspaceIdentifier, IWorkspaceIdentifier } from 'vs/platf
|
||||
import { ILayoutService, IDimension } from 'vs/platform/layout/browser/layoutService';
|
||||
import { SimpleServicesNLS } from 'vs/editor/common/standaloneStrings';
|
||||
import { ClassifiedEvent, StrictPropertyCheck, GDPRClassification } from 'vs/platform/telemetry/common/gdprTypings';
|
||||
import { basename } from 'vs/base/common/resources';
|
||||
|
||||
export class SimpleModel implements IResolvedTextEditorModel {
|
||||
|
||||
@@ -656,6 +657,7 @@ export class SimpleBulkEditService implements IBulkEditService {
|
||||
}
|
||||
|
||||
export class SimpleUriLabelService implements ILabelService {
|
||||
|
||||
_serviceBrand: any;
|
||||
|
||||
private readonly _onDidRegisterFormatter = new Emitter<void>();
|
||||
@@ -668,6 +670,10 @@ export class SimpleUriLabelService implements ILabelService {
|
||||
return resource.path;
|
||||
}
|
||||
|
||||
getUriBasenameLabel(resource: URI): string {
|
||||
return basename(resource);
|
||||
}
|
||||
|
||||
public getWorkspaceLabel(workspace: IWorkspaceIdentifier | URI | IWorkspace, options?: { verbose: boolean; }): string {
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import { IMenuItem, MenuId, MenuRegistry } from 'vs/platform/actions/common/acti
|
||||
import { CommandsRegistry, ICommandHandler, ICommandService } from 'vs/platform/commands/common/commands';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { ContextKeyExpr, IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { IContextViewService, IContextMenuService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { ContextViewService } from 'vs/platform/contextview/browser/contextViewService';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||
@@ -29,6 +29,7 @@ import { INotificationService } from 'vs/platform/notification/common/notificati
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility';
|
||||
import { StandaloneCodeEditorNLS } from 'vs/editor/common/standaloneStrings';
|
||||
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
|
||||
|
||||
/**
|
||||
* Description of an action contribution
|
||||
@@ -373,7 +374,9 @@ export class StandaloneDiffEditor extends DiffEditorWidget implements IStandalon
|
||||
@ICodeEditorService codeEditorService: ICodeEditorService,
|
||||
@IStandaloneThemeService themeService: IStandaloneThemeService,
|
||||
@INotificationService notificationService: INotificationService,
|
||||
@IConfigurationService configurationService: IConfigurationService
|
||||
@IConfigurationService configurationService: IConfigurationService,
|
||||
@IContextMenuService contextMenuService: IContextMenuService,
|
||||
@IClipboardService clipboardService: IClipboardService
|
||||
) {
|
||||
applyConfigurationValues(configurationService, options, true);
|
||||
options = options || {};
|
||||
@@ -381,7 +384,7 @@ export class StandaloneDiffEditor extends DiffEditorWidget implements IStandalon
|
||||
options.theme = themeService.setTheme(options.theme);
|
||||
}
|
||||
|
||||
super(domElement, options, editorWorkerService, contextKeyService, instantiationService, codeEditorService, themeService, notificationService);
|
||||
super(domElement, options, editorWorkerService, contextKeyService, instantiationService, codeEditorService, themeService, notificationService, contextMenuService, clipboardService);
|
||||
|
||||
this._contextViewService = <ContextViewService>contextViewService;
|
||||
this._configurationService = configurationService;
|
||||
|
||||
@@ -30,7 +30,7 @@ import { IStandaloneThemeData, IStandaloneThemeService } from 'vs/editor/standal
|
||||
import { ICommandService } from 'vs/platform/commands/common/commands';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { IContextViewService, IContextMenuService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { IMarker, IMarkerData } from 'vs/platform/markers/common/markers';
|
||||
@@ -38,6 +38,7 @@ import { INotificationService } from 'vs/platform/notification/common/notificati
|
||||
import { IOpenerService } from 'vs/platform/opener/common/opener';
|
||||
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility';
|
||||
import { clearAllFontInfos } from 'vs/editor/browser/config/configuration';
|
||||
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
|
||||
|
||||
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
||||
|
||||
@@ -119,6 +120,8 @@ export function createDiffEditor(domElement: HTMLElement, options?: IDiffEditorC
|
||||
services.get(IStandaloneThemeService),
|
||||
services.get(INotificationService),
|
||||
services.get(IConfigurationService),
|
||||
services.get(IContextMenuService),
|
||||
services.get(IClipboardService)
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -562,10 +562,10 @@ export function createMonacoLanguagesAPI(): typeof monaco.languages {
|
||||
// enums
|
||||
DocumentHighlightKind: standaloneEnums.DocumentHighlightKind,
|
||||
CompletionItemKind: standaloneEnums.CompletionItemKind,
|
||||
CompletionItemKindModifier: standaloneEnums.CompletionItemKindModifier,
|
||||
CompletionItemTag: standaloneEnums.CompletionItemTag,
|
||||
CompletionItemInsertTextRule: standaloneEnums.CompletionItemInsertTextRule,
|
||||
SymbolKind: standaloneEnums.SymbolKind,
|
||||
SymbolKindTag: standaloneEnums.SymbolKindTag,
|
||||
SymbolTag: standaloneEnums.SymbolTag,
|
||||
IndentAction: standaloneEnums.IndentAction,
|
||||
CompletionTriggerKind: standaloneEnums.CompletionTriggerKind,
|
||||
SignatureHelpTriggerKind: standaloneEnums.SignatureHelpTriggerKind,
|
||||
|
||||
Reference in New Issue
Block a user