Merge pull request #124996 from microsoft/hediet/isUndoRedo

Forwards the isUndoing/isRedoing flags to the extension host.
This commit is contained in:
Henning Dieterichs
2021-07-07 17:57:24 +02:00
committed by GitHub
8 changed files with 63 additions and 6 deletions

View File

@@ -1239,6 +1239,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
TextEditorLineNumbersStyle: extHostTypes.TextEditorLineNumbersStyle,
TextEditorRevealType: extHostTypes.TextEditorRevealType,
TextEditorSelectionChangeKind: extHostTypes.TextEditorSelectionChangeKind,
TextDocumentChangeReason: extHostTypes.TextDocumentChangeReason,
ThemeColor: extHostTypes.ThemeColor,
ThemeIcon: extHostTypes.ThemeIcon,
TreeItem: extHostTypes.TreeItem,

View File

@@ -14,6 +14,7 @@ import * as TypeConverters from 'vs/workbench/api/common/extHostTypeConverters';
import type * as vscode from 'vscode';
import { assertIsDefined } from 'vs/base/common/types';
import { deepFreeze } from 'vs/base/common/objects';
import { TextDocumentChangeReason } from 'vs/workbench/api/common/extHostTypes';
export class ExtHostDocuments implements ExtHostDocumentsShape {
@@ -134,7 +135,8 @@ export class ExtHostDocuments implements ExtHostDocumentsShape {
data._acceptIsDirty(isDirty);
this._onDidChangeDocument.fire({
document: data.document,
contentChanges: []
contentChanges: [],
reason: undefined
});
}
@@ -146,6 +148,14 @@ export class ExtHostDocuments implements ExtHostDocumentsShape {
}
data._acceptIsDirty(isDirty);
data.onEvents(events);
let reason: vscode.TextDocumentChangeReason | undefined = undefined;
if (events.isUndoing) {
reason = TextDocumentChangeReason.Undo;
} else if (events.isRedoing) {
reason = TextDocumentChangeReason.Redo;
}
this._onDidChangeDocument.fire(deepFreeze({
document: data.document,
contentChanges: events.changes.map((change) => {
@@ -155,7 +165,8 @@ export class ExtHostDocuments implements ExtHostDocumentsShape {
rangeLength: change.rangeLength,
text: change.text
};
})
}),
reason
}));
}

View File

@@ -1590,6 +1590,11 @@ export enum TextEditorSelectionChangeKind {
Command = 3
}
export enum TextDocumentChangeReason {
Undo = 1,
Redo = 2,
}
/**
* These values match very carefully the values of `TrackedRangeStickiness`
*/