From df16d1ab1dcbb68ed0e25722896eacf5cde5f023 Mon Sep 17 00:00:00 2001 From: shati-patel <42641846+shati-patel@users.noreply.github.com> Date: Wed, 5 Jan 2022 18:16:03 +0000 Subject: [PATCH] Results view: Don't reopen webview if it's already visible --- extensions/ql-vscode/src/interface.ts | 44 ++++++++++++++------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/extensions/ql-vscode/src/interface.ts b/extensions/ql-vscode/src/interface.ts index c5603029c..59f692bb0 100644 --- a/extensions/ql-vscode/src/interface.ts +++ b/extensions/ql-vscode/src/interface.ts @@ -379,27 +379,29 @@ export class InterfaceManager extends DisposableObject { const panel = this.getPanel(); await this.waitForPanelLoaded(); - if (forceReveal === WebviewReveal.Forced) { - panel.reveal(undefined, true); - } else if (!panel.visible) { - // The results panel exists, (`.getPanel()` guarantees it) but - // is not visible; it's in a not-currently-viewed tab. Show a - // more asynchronous message to not so abruptly interrupt - // user's workflow by immediately revealing the panel. - const showButton = 'View Results'; - const queryName = results.queryName; - const resultPromise = vscode.window.showInformationMessage( - `Finished running query ${queryName.length > 0 ? ` "${queryName}"` : '' - }.`, - showButton - ); - // Address this click asynchronously so we still update the - // query history immediately. - void resultPromise.then((result) => { - if (result === showButton) { - panel.reveal(); - } - }); + if (!panel.visible) { + if (forceReveal === WebviewReveal.Forced) { + panel.reveal(undefined, true); + } else { + // The results panel exists, (`.getPanel()` guarantees it) but + // is not visible; it's in a not-currently-viewed tab. Show a + // more asynchronous message to not so abruptly interrupt + // user's workflow by immediately revealing the panel. + const showButton = 'View Results'; + const queryName = results.queryName; + const resultPromise = vscode.window.showInformationMessage( + `Finished running query ${queryName.length > 0 ? ` "${queryName}"` : '' + }.`, + showButton + ); + // Address this click asynchronously so we still update the + // query history immediately. + void resultPromise.then((result) => { + if (result === showButton) { + panel.reveal(); + } + }); + } } // Note that the resultSetSchemas will return offsets for the default (unsorted) page,