mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-17 01:25:36 -05:00
Merge VS Code 1.23.1 (#1520)
This commit is contained in:
@@ -21,18 +21,20 @@ import { Configuration } from 'vs/editor/browser/config/configuration';
|
||||
import * as editorBrowser from 'vs/editor/browser/editorBrowser';
|
||||
import { View, IOverlayWidgetData, IContentWidgetData } from 'vs/editor/browser/view/viewImpl';
|
||||
import { Disposable, IDisposable } from 'vs/base/common/lifecycle';
|
||||
import Event, { Emitter } from 'vs/base/common/event';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent';
|
||||
import { InternalEditorAction } from 'vs/editor/common/editorAction';
|
||||
import { IEditorOptions } from 'vs/editor/common/config/editorOptions';
|
||||
import { IPosition } from 'vs/editor/common/core/position';
|
||||
import { IPosition, Position } from 'vs/editor/common/core/position';
|
||||
import { CoreEditorCommand } from 'vs/editor/browser/controller/coreCommands';
|
||||
import { IThemeService, registerThemingParticipant } from 'vs/platform/theme/common/themeService';
|
||||
import { editorErrorForeground, editorErrorBorder, editorWarningForeground, editorWarningBorder, editorInfoBorder, editorInfoForeground } from 'vs/editor/common/view/editorColorRegistry';
|
||||
import { editorErrorForeground, editorErrorBorder, editorWarningForeground, editorWarningBorder, editorInfoBorder, editorInfoForeground, editorHintForeground, editorHintBorder } from 'vs/editor/common/view/editorColorRegistry';
|
||||
import { Color } from 'vs/base/common/color';
|
||||
import { IMouseEvent } from 'vs/base/browser/mouseEvent';
|
||||
import { ClassName } from 'vs/editor/common/model/intervalTree';
|
||||
import { ITextModel, IModelDecorationOptions } from 'vs/editor/common/model';
|
||||
import { ICommandDelegate } from 'vs/editor/browser/view/viewController';
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
|
||||
export abstract class CodeEditorWidget extends CommonCodeEditor implements editorBrowser.ICodeEditor {
|
||||
|
||||
@@ -86,26 +88,22 @@ export abstract class CodeEditorWidget extends CommonCodeEditor implements edito
|
||||
constructor(
|
||||
domElement: HTMLElement,
|
||||
options: IEditorOptions,
|
||||
isSimpleWidget: boolean,
|
||||
@IInstantiationService instantiationService: IInstantiationService,
|
||||
@ICodeEditorService codeEditorService: ICodeEditorService,
|
||||
@ICommandService commandService: ICommandService,
|
||||
@IContextKeyService contextKeyService: IContextKeyService,
|
||||
@IThemeService themeService: IThemeService
|
||||
@IThemeService themeService: IThemeService,
|
||||
@INotificationService notificationService: INotificationService
|
||||
) {
|
||||
super(domElement, options, instantiationService, contextKeyService);
|
||||
super(domElement, options, isSimpleWidget, instantiationService, contextKeyService, notificationService);
|
||||
this._codeEditorService = codeEditorService;
|
||||
this._commandService = commandService;
|
||||
this._themeService = themeService;
|
||||
|
||||
this._focusTracker = new CodeEditorWidgetFocusTracker(domElement);
|
||||
this._focusTracker.onChange(() => {
|
||||
let hasFocus = this._focusTracker.hasFocus();
|
||||
|
||||
if (hasFocus) {
|
||||
this._onDidFocusEditor.fire();
|
||||
} else {
|
||||
this._onDidBlurEditor.fire();
|
||||
}
|
||||
this._editorFocus.setValue(this._focusTracker.hasFocus());
|
||||
});
|
||||
|
||||
this.contentWidgets = {};
|
||||
@@ -358,8 +356,62 @@ export abstract class CodeEditorWidget extends CommonCodeEditor implements edito
|
||||
}
|
||||
|
||||
protected _createView(): void {
|
||||
let commandDelegate: ICommandDelegate;
|
||||
if (this.isSimpleWidget) {
|
||||
commandDelegate = {
|
||||
paste: (source: string, text: string, pasteOnNewLine: boolean, multicursorText: string[]) => {
|
||||
this.cursor.trigger(source, editorCommon.Handler.Paste, { text, pasteOnNewLine, multicursorText });
|
||||
},
|
||||
type: (source: string, text: string) => {
|
||||
this.cursor.trigger(source, editorCommon.Handler.Type, { text });
|
||||
},
|
||||
replacePreviousChar: (source: string, text: string, replaceCharCnt: number) => {
|
||||
this.cursor.trigger(source, editorCommon.Handler.ReplacePreviousChar, { text, replaceCharCnt });
|
||||
},
|
||||
compositionStart: (source: string) => {
|
||||
this.cursor.trigger(source, editorCommon.Handler.CompositionStart, undefined);
|
||||
},
|
||||
compositionEnd: (source: string) => {
|
||||
this.cursor.trigger(source, editorCommon.Handler.CompositionEnd, undefined);
|
||||
},
|
||||
cut: (source: string) => {
|
||||
this.cursor.trigger(source, editorCommon.Handler.Cut, undefined);
|
||||
}
|
||||
};
|
||||
} else {
|
||||
commandDelegate = {
|
||||
paste: (source: string, text: string, pasteOnNewLine: boolean, multicursorText: string[]) => {
|
||||
this._commandService.executeCommand(editorCommon.Handler.Paste, {
|
||||
text: text,
|
||||
pasteOnNewLine: pasteOnNewLine,
|
||||
multicursorText: multicursorText
|
||||
});
|
||||
},
|
||||
type: (source: string, text: string) => {
|
||||
this._commandService.executeCommand(editorCommon.Handler.Type, {
|
||||
text: text
|
||||
});
|
||||
},
|
||||
replacePreviousChar: (source: string, text: string, replaceCharCnt: number) => {
|
||||
this._commandService.executeCommand(editorCommon.Handler.ReplacePreviousChar, {
|
||||
text: text,
|
||||
replaceCharCnt: replaceCharCnt
|
||||
});
|
||||
},
|
||||
compositionStart: (source: string) => {
|
||||
this._commandService.executeCommand(editorCommon.Handler.CompositionStart, {});
|
||||
},
|
||||
compositionEnd: (source: string) => {
|
||||
this._commandService.executeCommand(editorCommon.Handler.CompositionEnd, {});
|
||||
},
|
||||
cut: (source: string) => {
|
||||
this._commandService.executeCommand(editorCommon.Handler.Cut, {});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
this._view = new View(
|
||||
this._commandService,
|
||||
commandDelegate,
|
||||
this._configuration,
|
||||
this._themeService,
|
||||
this.viewModel,
|
||||
@@ -375,13 +427,13 @@ export abstract class CodeEditorWidget extends CommonCodeEditor implements edito
|
||||
const viewEventBus = this._view.getInternalEventBus();
|
||||
|
||||
viewEventBus.onDidGainFocus = () => {
|
||||
this._onDidFocusEditorText.fire();
|
||||
this._editorTextFocus.setValue(true);
|
||||
// In IE, the focus is not synchronous, so we give it a little help
|
||||
this._onDidFocusEditor.fire();
|
||||
this._editorFocus.setValue(true);
|
||||
};
|
||||
|
||||
viewEventBus.onDidScroll = (e) => this._onDidScrollChange.fire(e);
|
||||
viewEventBus.onDidLoseFocus = () => this._onDidBlurEditorText.fire();
|
||||
viewEventBus.onDidLoseFocus = () => this._editorTextFocus.setValue(false);
|
||||
viewEventBus.onContextMenu = (e) => this._onContextMenu.fire(e);
|
||||
viewEventBus.onMouseDown = (e) => this._onMouseDown.fire(e);
|
||||
viewEventBus.onMouseUp = (e) => this._onMouseUp.fire(e);
|
||||
@@ -399,7 +451,12 @@ export abstract class CodeEditorWidget extends CommonCodeEditor implements edito
|
||||
return;
|
||||
}
|
||||
if (s && s.cursorState && s.viewState) {
|
||||
this._view.restoreState(this.viewModel.viewLayout.reduceRestoreState(s.viewState));
|
||||
const reducedState = this.viewModel.reduceRestoreState(s.viewState);
|
||||
const linesViewportData = this.viewModel.viewLayout.getLinesViewportDataAtScrollTop(reducedState.scrollTop);
|
||||
const startPosition = this.viewModel.coordinatesConverter.convertViewPositionToModelPosition(new Position(linesViewportData.startLineNumber, 1));
|
||||
const endPosition = this.viewModel.coordinatesConverter.convertViewPositionToModelPosition(new Position(linesViewportData.endLineNumber, 1));
|
||||
this.model.tokenizeViewport(startPosition.lineNumber, endPosition.lineNumber);
|
||||
this._view.restoreState(reducedState);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -455,8 +512,8 @@ class CodeEditorWidgetFocusTracker extends Disposable {
|
||||
private _hasFocus: boolean;
|
||||
private _domFocusTracker: dom.IFocusTracker;
|
||||
|
||||
private _onChange: Emitter<void> = this._register(new Emitter<void>());
|
||||
public onChange: Event<void> = this._onChange.event;
|
||||
private readonly _onChange: Emitter<void> = this._register(new Emitter<void>());
|
||||
public readonly onChange: Event<void> = this._onChange.event;
|
||||
|
||||
constructor(domElement: HTMLElement) {
|
||||
super();
|
||||
@@ -486,6 +543,13 @@ function getSquigglySVGData(color: Color) {
|
||||
return squigglyStart + encodeURIComponent(color.toString()) + squigglyEnd;
|
||||
}
|
||||
|
||||
const dotdotdotStart = encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" height="3" width="12"><g fill="`);
|
||||
const dotdotdotEnd = encodeURIComponent(`"><circle cx="1" cy="1" r="1"/><circle cx="5" cy="1" r="1"/><circle cx="9" cy="1" r="1"/></g></svg>`);
|
||||
|
||||
function getDotDotDotSVGData(color: Color) {
|
||||
return dotdotdotStart + encodeURIComponent(color.toString()) + dotdotdotEnd;
|
||||
}
|
||||
|
||||
registerThemingParticipant((theme, collector) => {
|
||||
let errorBorderColor = theme.getColor(editorErrorBorder);
|
||||
if (errorBorderColor) {
|
||||
@@ -513,4 +577,13 @@ registerThemingParticipant((theme, collector) => {
|
||||
if (infoForeground) {
|
||||
collector.addRule(`.monaco-editor .${ClassName.EditorInfoDecoration} { background: url("data:image/svg+xml;utf8,${getSquigglySVGData(infoForeground)}") repeat-x bottom left; }`);
|
||||
}
|
||||
|
||||
let hintBorderColor = theme.getColor(editorHintBorder);
|
||||
if (hintBorderColor) {
|
||||
collector.addRule(`.monaco-editor .${ClassName.EditorHintDecoration} { border-bottom: 2px dotted ${hintBorderColor}; }`);
|
||||
}
|
||||
let hintForeground = theme.getColor(editorHintForeground);
|
||||
if (hintForeground) {
|
||||
collector.addRule(`.monaco-editor .${ClassName.EditorHintDecoration} { background: url("data:image/svg+xml;utf8,${getDotDotDotSVGData(hintForeground)}") no-repeat bottom left; }`);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user