From b18bb26f97ffbdec72880a865c4e12725eb94b69 Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Mon, 6 Mar 2023 17:04:13 +0100 Subject: [PATCH] better undo experience (#176247) --- .../interactive/browser/interactiveEditorWidget.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/vs/editor/contrib/interactive/browser/interactiveEditorWidget.ts b/src/vs/editor/contrib/interactive/browser/interactiveEditorWidget.ts index 1c69b074ab7..1b4f701fe91 100644 --- a/src/vs/editor/contrib/interactive/browser/interactiveEditorWidget.ts +++ b/src/vs/editor/contrib/interactive/browser/interactiveEditorWidget.ts @@ -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); }