Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/microsoft/vscode.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Dima <alexdima@microsoft.com>2019-10-14 22:18:19 +0300
committerAlex Dima <alexdima@microsoft.com>2019-10-14 22:18:37 +0300
commite4a4ea2b26f5754ac49b6beff1b29f4cb21d703f (patch)
treef9185c1ac92b6163dabd69fd7b066e8b2b1882af
parent0d9307ff597666896bc02d0d8cad84de193f2f7e (diff)
Keep track of the diff computation state
-rw-r--r--src/vs/editor/browser/editorBrowser.ts9
-rw-r--r--src/vs/editor/browser/widget/diffEditorWidget.ts15
2 files changed, 22 insertions, 2 deletions
diff --git a/src/vs/editor/browser/editorBrowser.ts b/src/vs/editor/browser/editorBrowser.ts
index 0253876b502..74d75937ecb 100644
--- a/src/vs/editor/browser/editorBrowser.ts
+++ b/src/vs/editor/browser/editorBrowser.ts
@@ -836,6 +836,15 @@ export interface IDiffLineInformation {
}
/**
+ * @internal
+ */
+export const enum DiffEditorState {
+ Idle,
+ ComputingDiff,
+ DiffComputed
+}
+
+/**
* A rich diff editor.
*/
export interface IDiffEditor extends editorCommon.IEditor {
diff --git a/src/vs/editor/browser/widget/diffEditorWidget.ts b/src/vs/editor/browser/widget/diffEditorWidget.ts
index 1ac2ad30699..67c9920f662 100644
--- a/src/vs/editor/browser/widget/diffEditorWidget.ts
+++ b/src/vs/editor/browser/widget/diffEditorWidget.ts
@@ -167,6 +167,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
public readonly onDidUpdateDiff: Event<void> = this._onDidUpdateDiff.event;
private readonly id: number;
+ private _state: editorBrowser.DiffEditorState;
private readonly _domElement: HTMLElement;
protected readonly _containerDomElement: HTMLElement;
@@ -236,6 +237,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
this._notificationService = notificationService;
this.id = (++DIFF_EDITOR_ID);
+ this._state = editorBrowser.DiffEditorState.Idle;
this._domElement = domElement;
options = options || {};
@@ -391,6 +393,13 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
return this._renderIndicators;
}
+ private _setState(newState: editorBrowser.DiffEditorState): void {
+ if (this._state !== newState) {
+ return;
+ }
+ this._state = newState;
+ }
+
public hasWidgetFocus(): boolean {
return dom.isAncestor(document.activeElement, this._domElement);
}
@@ -678,14 +687,13 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
// Disable any diff computations that will come in
this._diffComputationResult = null;
this._diffComputationToken++;
+ this._setState(editorBrowser.DiffEditorState.Idle);
if (model) {
this._recreateOverviewRulers();
// Begin comparing
this._beginUpdateDecorations();
- } else {
- this._diffComputationResult = null;
}
this._layoutOverviewViewport();
@@ -933,6 +941,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
// yet supported, so using tokens for now.
this._diffComputationToken++;
let currentToken = this._diffComputationToken;
+ this._setState(editorBrowser.DiffEditorState.ComputingDiff);
if (!this._editorWorkerService.canComputeDiff(currentOriginalModel.uri, currentModifiedModel.uri)) {
if (
@@ -951,6 +960,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
&& currentOriginalModel === this.originalEditor.getModel()
&& currentModifiedModel === this.modifiedEditor.getModel()
) {
+ this._setState(editorBrowser.DiffEditorState.DiffComputed);
this._diffComputationResult = result;
this._updateDecorationsRunner.schedule();
this._onDidUpdateDiff.fire();
@@ -960,6 +970,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
&& currentOriginalModel === this.originalEditor.getModel()
&& currentModifiedModel === this.modifiedEditor.getModel()
) {
+ this._setState(editorBrowser.DiffEditorState.DiffComputed);
this._diffComputationResult = null;
this._updateDecorationsRunner.schedule();
}