Skip to content

Commit 71b0a72

Browse files
authored
Avoid losing chat input after accidentally navigating history (microsoft#205977)
Fix microsoft/vscode-copilot-release#661
1 parent fa7b644 commit 71b0a72

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/vs/workbench/contrib/chat/browser/chatInputPart.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
8686
private historyNavigationBackwardsEnablement!: IContextKey<boolean>;
8787
private historyNavigationForewardsEnablement!: IContextKey<boolean>;
8888
private onHistoryEntry = false;
89+
private inHistoryNavigation = false;
8990
private inputModel: ITextModel | undefined;
9091
private inputEditorHasText: IContextKey<boolean>;
9192
private chatCursorAtTop: IContextKey<boolean>;
@@ -160,7 +161,11 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
160161
this.onHistoryEntry = previous || this.history.current() !== null;
161162

162163
aria.status(historyEntry.text);
164+
165+
this.inHistoryNavigation = true;
163166
this.setValue(historyEntry.text);
167+
this.inHistoryNavigation = false;
168+
164169
this._onDidLoadInputState.fire(historyEntry.state);
165170
if (previous) {
166171
this._inputEditor.setPosition({ lineNumber: 1, column: 1 });
@@ -269,6 +274,12 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
269274
const model = this._inputEditor.getModel();
270275
const inputHasText = !!model && model.getValueLength() > 0;
271276
this.inputEditorHasText.set(inputHasText);
277+
278+
// If the user is typing on a history entry, then reset the onHistoryEntry flag so that history navigation can be disabled
279+
if (!this.inHistoryNavigation) {
280+
this.onHistoryEntry = false;
281+
}
282+
272283
if (!this.onHistoryEntry) {
273284
this.historyNavigationForewardsEnablement.set(!inputHasText);
274285
this.historyNavigationBackwardsEnablement.set(!inputHasText);

0 commit comments

Comments
 (0)