better undo experience (#176247)

This commit is contained in:
Johannes Rieken
2023-03-06 17:04:13 +01:00
committed by GitHub
parent 728ee42999
commit b18bb26f97
@@ -684,16 +684,16 @@ export class InteractiveEditorController implements IEditorContribution {
options: InteractiveEditorController._decoBlock
}]);
this._ctsRequest?.dispose(true);
this._ctsRequest = new CancellationTokenSource(this._ctsSession.token);
this._historyOffset = -1;
const input = await this._zone.getInput(wholeRange.getEndPosition(), placeholder, value, this._ctsSession.token);
const input = await this._zone.getInput(wholeRange.getEndPosition(), placeholder, value, this._ctsRequest.token);
if (!input || !input.value) {
continue;
}
this._ctsRequest?.dispose(true);
this._ctsRequest = new CancellationTokenSource(this._ctsSession.token);
const historyEntry = this._zone.widget.createHistoryEntry(input.value);
const sw = StopWatch.create();
@@ -772,6 +772,7 @@ export class InteractiveEditorController implements IEditorContribution {
inlineDiffDecorations.set(input.preview ? newInlineDiffDecorationsData : []);
const that = this;
historyEntry.updateActions([new class extends UndoStepAction {
constructor() {
super(textModel);
@@ -780,10 +781,10 @@ export class InteractiveEditorController implements IEditorContribution {
super.run();
historyEntry.updateVisibility(false);
value = input.value;
that._ctsRequest?.cancel();
}
}]);
if (!InteractiveEditorController._promptHistory.includes(input.value)) {
InteractiveEditorController._promptHistory.unshift(input.value);
}