Skip to content

Commit 6e95696

Browse files
authored
Merge pull request microsoft#196598 from microsoft/tyriar/2353
Clear partial query quick chats when closed
2 parents 904c88e + 5aab93b commit 6e95696

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import * as dom from 'vs/base/browser/dom';
77
import { Orientation, Sash } from 'vs/base/browser/ui/sash/sash';
88
import { disposableTimeout } from 'vs/base/common/async';
99
import { CancellationToken } from 'vs/base/common/cancellation';
10-
import { Emitter } from 'vs/base/common/event';
10+
import { Emitter, Event } from 'vs/base/common/event';
1111
import { Disposable, DisposableStore, IDisposable, MutableDisposable } from 'vs/base/common/lifecycle';
1212
import { Selection } from 'vs/editor/common/core/selection';
1313
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
@@ -61,6 +61,14 @@ export class QuickChatService extends Disposable implements IQuickChatService {
6161
this.close();
6262
} else {
6363
this.open(providerId, options);
64+
// If this is a partial query, the value should be cleared when closed as otherwise it
65+
// would remain for the next time the quick chat is opened in any context.
66+
if (options?.isPartialQuery) {
67+
const disposable = this._store.add(Event.once(this.onDidClose)(() => {
68+
this._currentChat?.clearValue();
69+
this._store.delete(disposable);
70+
}));
71+
}
6472
}
6573
}
6674

@@ -300,6 +308,10 @@ class QuickChat extends Disposable {
300308
this.focus(selection);
301309
}
302310

311+
clearValue(): void {
312+
this.widget.inputEditor.setValue('');
313+
}
314+
303315
private updateModel(): void {
304316
this.model ??= this.chatService.startSession(this._options.providerId, CancellationToken.None);
305317
if (!this.model) {

0 commit comments

Comments
 (0)