From cf0879dd27aa7a52e431c5dafcb55604add6c8d9 Mon Sep 17 00:00:00 2001 From: isidor Date: Thu, 6 Dec 2018 14:11:07 +0100 Subject: [PATCH] repl: reveal last element when session change fixes #64397 --- src/vs/workbench/parts/debug/electron-browser/repl.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/vs/workbench/parts/debug/electron-browser/repl.ts b/src/vs/workbench/parts/debug/electron-browser/repl.ts index db7ee891495..dc97bd898f4 100644 --- a/src/vs/workbench/parts/debug/electron-browser/repl.ts +++ b/src/vs/workbench/parts/debug/electron-browser/repl.ts @@ -82,6 +82,10 @@ interface IPrivateReplService { clearRepl(): void; } +function revealLastElement(tree: WorkbenchAsyncDataTree) { + tree.scrollTop = tree.scrollHeight - tree.renderHeight; +} + const sessionsToIgnore = new Set(); export class Repl extends Panel implements IPrivateReplService, IHistoryNavigationWidget { _serviceBrand: any; @@ -209,7 +213,7 @@ export class Repl extends Panel implements IPrivateReplService, IHistoryNavigati if (this.tree && this.dataSource.input !== session) { this.dataSource.input = session; - this.tree.refresh(null); + this.tree.refresh(null).then(() => revealLastElement(this.tree)); } } @@ -235,8 +239,7 @@ export class Repl extends Panel implements IPrivateReplService, IHistoryNavigati const session: IDebugSession = this.dataSource.input; if (session) { session.addReplExpression(this.debugService.getViewModel().focusedStackFrame, this.replInput.getValue()); - // Reveal last element when we add new expression - this.tree.scrollTop = this.tree.scrollHeight - this.tree.renderHeight; + revealLastElement(this.tree); this.history.add(this.replInput.getValue()); this.replInput.setValue(''); const shouldRelayout = this.replInputHeight > Repl.REPL_INPUT_INITIAL_HEIGHT; -- GitLab