Results view: Don't reopen webview if it's already visible

This commit is contained in:
shati-patel
2022-01-05 18:16:03 +00:00
committed by Shati Patel
parent b661b2be97
commit df16d1ab1d

View File

@@ -379,27 +379,29 @@ export class InterfaceManager extends DisposableObject {
const panel = this.getPanel(); const panel = this.getPanel();
await this.waitForPanelLoaded(); await this.waitForPanelLoaded();
if (forceReveal === WebviewReveal.Forced) { if (!panel.visible) {
panel.reveal(undefined, true); if (forceReveal === WebviewReveal.Forced) {
} else if (!panel.visible) { panel.reveal(undefined, true);
// The results panel exists, (`.getPanel()` guarantees it) but } else {
// is not visible; it's in a not-currently-viewed tab. Show a // The results panel exists, (`.getPanel()` guarantees it) but
// more asynchronous message to not so abruptly interrupt // is not visible; it's in a not-currently-viewed tab. Show a
// user's workflow by immediately revealing the panel. // more asynchronous message to not so abruptly interrupt
const showButton = 'View Results'; // user's workflow by immediately revealing the panel.
const queryName = results.queryName; const showButton = 'View Results';
const resultPromise = vscode.window.showInformationMessage( const queryName = results.queryName;
`Finished running query ${queryName.length > 0 ? ` "${queryName}"` : '' const resultPromise = vscode.window.showInformationMessage(
}.`, `Finished running query ${queryName.length > 0 ? ` "${queryName}"` : ''
showButton }.`,
); showButton
// Address this click asynchronously so we still update the );
// query history immediately. // Address this click asynchronously so we still update the
void resultPromise.then((result) => { // query history immediately.
if (result === showButton) { void resultPromise.then((result) => {
panel.reveal(); if (result === showButton) {
} panel.reveal();
}); }
});
}
} }
// Note that the resultSetSchemas will return offsets for the default (unsorted) page, // Note that the resultSetSchemas will return offsets for the default (unsorted) page,