Skip to content

Commit 336db9e

Browse files
authored
stop inline chat reveal on any vertical scroll (microsoft#227207)
microsoft/vscode-copilot#7338
1 parent 5376d85 commit 336db9e

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

src/vs/workbench/contrib/inlineChat/browser/inlineChatZoneWidget.ts

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,9 @@ export class InlineChatZoneWidget extends ZoneWidget {
188188
return isResponseVM(candidate) && candidate.response.value.length > 0;
189189
});
190190

191-
if (hasResponse && zoneTop < scrollTop || this._scrollUp.didScrollUp) {
191+
if (hasResponse && zoneTop < scrollTop || this._scrollUp.didScrollUpOrDown) {
192192
// don't reveal the zone if it is already out of view (unless we are still getting ready)
193-
// or if an outside scroll-up happened (e.g the user scrolled up to see the new content)
193+
// or if an outside scroll-up happened (e.g the user scrolled up/down to see the new content)
194194
return this._scrollUp.runIgnored(() => {
195195
scrollState.restore(this.editor);
196196
});
@@ -244,8 +244,7 @@ export class InlineChatZoneWidget extends ZoneWidget {
244244

245245
class ScrollUpState {
246246

247-
private _lastScrollTop: number = this._editor.getScrollTop();
248-
private _didScrollUp?: boolean;
247+
private _didScrollUpOrDown?: boolean;
249248
private _ignoreEvents = false;
250249

251250
private readonly _listener = new MutableDisposable();
@@ -257,23 +256,19 @@ class ScrollUpState {
257256
}
258257

259258
enable(): void {
260-
this._didScrollUp = undefined;
259+
this._didScrollUpOrDown = undefined;
261260
this._listener.value = this._editor.onDidScrollChange(e => {
262261
if (!e.scrollTopChanged || this._ignoreEvents) {
263262
return;
264263
}
265-
const currentScrollTop = e.scrollTop;
266-
if (currentScrollTop > this._lastScrollTop) {
267-
this._listener.clear();
268-
this._didScrollUp = true;
269-
}
270-
this._lastScrollTop = currentScrollTop;
264+
this._listener.clear();
265+
this._didScrollUpOrDown = true;
271266
});
272267
}
273268

274269
disable(): void {
275270
this._listener.clear();
276-
this._didScrollUp = undefined;
271+
this._didScrollUpOrDown = undefined;
277272
}
278273

279274
runIgnored(callback: () => void): () => void {
@@ -287,8 +282,8 @@ class ScrollUpState {
287282
};
288283
}
289284

290-
get didScrollUp(): boolean | undefined {
291-
return this._didScrollUp;
285+
get didScrollUpOrDown(): boolean | undefined {
286+
return this._didScrollUpOrDown;
292287
}
293288

294289
}

0 commit comments

Comments
 (0)