mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-08 09:38:26 -05:00
Merge from vscode 1b314ab317fbff7d799b21754326b7d849889ceb
This commit is contained in:
@@ -20,6 +20,7 @@ import { equals } from 'vs/base/common/arrays';
|
||||
import { CodeEditorStateFlag, EditorState } from 'vs/editor/browser/core/editorState';
|
||||
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
|
||||
import { SnippetParser } from 'vs/editor/contrib/snippet/snippetParser';
|
||||
import { MainThreadDocuments } from 'vs/workbench/api/browser/mainThreadDocuments';
|
||||
|
||||
export interface IFocusTracker {
|
||||
onGainedFocus(): void;
|
||||
@@ -160,7 +161,8 @@ export class MainThreadTextEditorProperties {
|
||||
export class MainThreadTextEditor {
|
||||
|
||||
private readonly _id: string;
|
||||
private _model: ITextModel;
|
||||
private readonly _model: ITextModel;
|
||||
private readonly _mainThreadDocuments: MainThreadDocuments;
|
||||
private readonly _modelService: IModelService;
|
||||
private readonly _clipboardService: IClipboardService;
|
||||
private readonly _modelListeners = new DisposableStore();
|
||||
@@ -176,6 +178,7 @@ export class MainThreadTextEditor {
|
||||
model: ITextModel,
|
||||
codeEditor: ICodeEditor,
|
||||
focusTracker: IFocusTracker,
|
||||
mainThreadDocuments: MainThreadDocuments,
|
||||
modelService: IModelService,
|
||||
clipboardService: IClipboardService,
|
||||
) {
|
||||
@@ -184,6 +187,7 @@ export class MainThreadTextEditor {
|
||||
this._codeEditor = null;
|
||||
this._properties = null;
|
||||
this._focusTracker = focusTracker;
|
||||
this._mainThreadDocuments = mainThreadDocuments;
|
||||
this._modelService = modelService;
|
||||
this._clipboardService = clipboardService;
|
||||
|
||||
@@ -198,7 +202,6 @@ export class MainThreadTextEditor {
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
this._model = null!;
|
||||
this._modelListeners.dispose();
|
||||
this._codeEditor = null;
|
||||
this._codeEditorListeners.dispose();
|
||||
@@ -257,21 +260,46 @@ export class MainThreadTextEditor {
|
||||
this._focusTracker.onLostFocus();
|
||||
}));
|
||||
|
||||
let nextSelectionChangeSource: string | null = null;
|
||||
this._codeEditorListeners.add(this._mainThreadDocuments.onIsCaughtUpWithContentChanges((uri) => {
|
||||
if (uri.toString() === this._model.uri.toString()) {
|
||||
const selectionChangeSource = nextSelectionChangeSource;
|
||||
nextSelectionChangeSource = null;
|
||||
this._updatePropertiesNow(selectionChangeSource);
|
||||
}
|
||||
}));
|
||||
|
||||
const updateProperties = (selectionChangeSource: string | null) => {
|
||||
// Some editor events get delivered faster than model content changes. This is
|
||||
// problematic, as this leads to editor properties reaching the extension host
|
||||
// too soon, before the model content change that was the root cause.
|
||||
//
|
||||
// If this case is identified, then let's update editor properties on the next model
|
||||
// content change instead.
|
||||
if (this._mainThreadDocuments.isCaughtUpWithContentChanges(this._model.uri)) {
|
||||
nextSelectionChangeSource = null;
|
||||
this._updatePropertiesNow(selectionChangeSource);
|
||||
} else {
|
||||
// update editor properties on the next model content change
|
||||
nextSelectionChangeSource = selectionChangeSource;
|
||||
}
|
||||
};
|
||||
|
||||
this._codeEditorListeners.add(this._codeEditor.onDidChangeCursorSelection((e) => {
|
||||
// selection
|
||||
this._updatePropertiesNow(e.source);
|
||||
updateProperties(e.source);
|
||||
}));
|
||||
this._codeEditorListeners.add(this._codeEditor.onDidChangeConfiguration(() => {
|
||||
// options
|
||||
this._updatePropertiesNow(null);
|
||||
updateProperties(null);
|
||||
}));
|
||||
this._codeEditorListeners.add(this._codeEditor.onDidLayoutChange(() => {
|
||||
// visibleRanges
|
||||
this._updatePropertiesNow(null);
|
||||
updateProperties(null);
|
||||
}));
|
||||
this._codeEditorListeners.add(this._codeEditor.onDidScrollChange(() => {
|
||||
// visibleRanges
|
||||
this._updatePropertiesNow(null);
|
||||
updateProperties(null);
|
||||
}));
|
||||
this._updatePropertiesNow(null);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user