Skip to content

Commit 9e927a6

Browse files
After 30s re-layout the quick chat (microsoft#191853)
fixes microsoft#191627
1 parent e7756c8 commit 9e927a6

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55

66
import * as dom from 'vs/base/browser/dom';
77
import { Orientation, Sash } from 'vs/base/browser/ui/sash/sash';
8+
import { disposableTimeout } from 'vs/base/common/async';
89
import { CancellationToken } from 'vs/base/common/cancellation';
910
import { Emitter } from 'vs/base/common/event';
10-
import { Disposable, DisposableStore } from 'vs/base/common/lifecycle';
11+
import { Disposable, DisposableStore, IDisposable, MutableDisposable } from 'vs/base/common/lifecycle';
1112
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
1213
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
1314
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
@@ -132,6 +133,7 @@ class QuickChat extends Disposable {
132133
private sash!: Sash;
133134
private model: ChatModel | undefined;
134135
private _currentQuery: string | undefined;
136+
private maintainScrollTimer: MutableDisposable<IDisposable> = this._register(new MutableDisposable<IDisposable>());
135137

136138
constructor(
137139
private readonly _options: IChatViewOptions,
@@ -168,10 +170,22 @@ class QuickChat extends Disposable {
168170

169171
hide(): void {
170172
this.widget.setVisible(false);
173+
// Maintain scroll position for a short time so that if the user re-shows the chat
174+
// the same scroll position will be used.
175+
this.maintainScrollTimer.value = disposableTimeout(() => {
176+
// At this point, clear this mutable disposable which will be our signal that
177+
// the timer has expired and we should stop maintaining scroll position
178+
this.maintainScrollTimer.clear();
179+
}, 30 * 1000); // 30 seconds
171180
}
172181

173182
show(): void {
174183
this.widget.setVisible(true);
184+
// If the mutable disposable is set, then we are keeping the existing scroll position
185+
// so we should not update the layout.
186+
if (!this.maintainScrollTimer.value) {
187+
this.widget.layoutDynamicChatTreeItemMode();
188+
}
175189
}
176190

177191
render(parent: HTMLElement): void {

0 commit comments

Comments
 (0)