|
5 | 5 |
|
6 | 6 | import * as dom from 'vs/base/browser/dom';
|
7 | 7 | import { Orientation, Sash } from 'vs/base/browser/ui/sash/sash';
|
| 8 | +import { disposableTimeout } from 'vs/base/common/async'; |
8 | 9 | import { CancellationToken } from 'vs/base/common/cancellation';
|
9 | 10 | 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'; |
11 | 12 | import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
12 | 13 | import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
13 | 14 | import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
|
@@ -132,6 +133,7 @@ class QuickChat extends Disposable {
|
132 | 133 | private sash!: Sash;
|
133 | 134 | private model: ChatModel | undefined;
|
134 | 135 | private _currentQuery: string | undefined;
|
| 136 | + private maintainScrollTimer: MutableDisposable<IDisposable> = this._register(new MutableDisposable<IDisposable>()); |
135 | 137 |
|
136 | 138 | constructor(
|
137 | 139 | private readonly _options: IChatViewOptions,
|
@@ -168,10 +170,22 @@ class QuickChat extends Disposable {
|
168 | 170 |
|
169 | 171 | hide(): void {
|
170 | 172 | 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 |
171 | 180 | }
|
172 | 181 |
|
173 | 182 | show(): void {
|
174 | 183 | 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 | + } |
175 | 189 | }
|
176 | 190 |
|
177 | 191 | render(parent: HTMLElement): void {
|
|
0 commit comments