Skip to content

Commit 9595f43

Browse files
committed
Fix chat input history navigation
Fix microsoft/vscode-copilot-release#661
1 parent 12443ca commit 9595f43

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

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

+12-2
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
8686
private historyStates: Map<string, any> = new Map();
8787
private historyNavigationBackwardsEnablement!: IContextKey<boolean>;
8888
private historyNavigationForewardsEnablement!: IContextKey<boolean>;
89+
private onHistoryEntry = false;
8990
private inputModel: ITextModel | undefined;
9091
private inputEditorHasText: IContextKey<boolean>;
9192
private chatCursorAtTop: IContextKey<boolean>;
@@ -161,6 +162,8 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
161162
(this.history.previous() ?? this.history.first()) : this.history.next())
162163
?? '';
163164

165+
this.onHistoryEntry = previous || this.history.current() !== null;
166+
164167
aria.status(historyInput);
165168
this.setValue(historyInput);
166169
this._onDidLoadInputState.fire(this.historyStates.get(historyInput));
@@ -272,6 +275,10 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
272275
const model = this._inputEditor.getModel();
273276
const inputHasText = !!model && model.getValueLength() > 0;
274277
this.inputEditorHasText.set(inputHasText);
278+
if (!this.onHistoryEntry) {
279+
this.historyNavigationForewardsEnablement.set(!inputHasText);
280+
this.historyNavigationBackwardsEnablement.set(!inputHasText);
281+
}
275282
}));
276283
this._register(this._inputEditor.onDidFocusEditorText(() => {
277284
this._onDidFocus.fire();
@@ -289,9 +296,12 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
289296
}
290297

291298
const atTop = e.position.column === 1 && e.position.lineNumber === 1;
292-
this.historyNavigationBackwardsEnablement.set(atTop);
293299
this.chatCursorAtTop.set(atTop);
294-
this.historyNavigationForewardsEnablement.set(e.position.equals(getLastPosition(model)));
300+
301+
if (this.onHistoryEntry) {
302+
this.historyNavigationBackwardsEnablement.set(atTop);
303+
this.historyNavigationForewardsEnablement.set(e.position.equals(getLastPosition(model)));
304+
}
295305
}));
296306

297307
this.toolbar = this._register(this.instantiationService.createInstance(MenuWorkbenchToolBar, inputContainer, MenuId.ChatExecute, {

0 commit comments

Comments
 (0)