mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 04:49:35 +00:00
Avoid losing chat input after accidentally navigating history (#205977)
Fix microsoft/vscode-copilot-release#661
This commit is contained in:
parent
fa7b64426e
commit
71b0a729fe
|
@ -86,6 +86,7 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
|
|||
private historyNavigationBackwardsEnablement!: IContextKey<boolean>;
|
||||
private historyNavigationForewardsEnablement!: IContextKey<boolean>;
|
||||
private onHistoryEntry = false;
|
||||
private inHistoryNavigation = false;
|
||||
private inputModel: ITextModel | undefined;
|
||||
private inputEditorHasText: IContextKey<boolean>;
|
||||
private chatCursorAtTop: IContextKey<boolean>;
|
||||
|
@ -160,7 +161,11 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
|
|||
this.onHistoryEntry = previous || this.history.current() !== null;
|
||||
|
||||
aria.status(historyEntry.text);
|
||||
|
||||
this.inHistoryNavigation = true;
|
||||
this.setValue(historyEntry.text);
|
||||
this.inHistoryNavigation = false;
|
||||
|
||||
this._onDidLoadInputState.fire(historyEntry.state);
|
||||
if (previous) {
|
||||
this._inputEditor.setPosition({ lineNumber: 1, column: 1 });
|
||||
|
@ -269,6 +274,12 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
|
|||
const model = this._inputEditor.getModel();
|
||||
const inputHasText = !!model && model.getValueLength() > 0;
|
||||
this.inputEditorHasText.set(inputHasText);
|
||||
|
||||
// If the user is typing on a history entry, then reset the onHistoryEntry flag so that history navigation can be disabled
|
||||
if (!this.inHistoryNavigation) {
|
||||
this.onHistoryEntry = false;
|
||||
}
|
||||
|
||||
if (!this.onHistoryEntry) {
|
||||
this.historyNavigationForewardsEnablement.set(!inputHasText);
|
||||
this.historyNavigationBackwardsEnablement.set(!inputHasText);
|
||||
|
|
Loading…
Reference in a new issue