Skip to content

Commit

Permalink
fix query focus for all scenarios (#1543)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aditya Bist committed Dec 12, 2019
1 parent 44f17e8 commit e3d42ca
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
19 changes: 13 additions & 6 deletions src/controllers/webviewController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,16 @@ export class WebviewPanelController implements vscode.Disposable {
const config = this._vscodeWrapper.getConfiguration(Constants.extensionConfigSectionName, vscode.Uri.parse(uri));
const retainContextWhenHidden = config[Constants.configPersistQueryResultTabs];
const column = this.newResultPaneViewColumn(uri);
this._disposables.push(this._panel = vscode.window.createWebviewPanel(uri, title, column, {
retainContextWhenHidden,
enableScripts: true
}));
this._disposables.push(this._panel = vscode.window.createWebviewPanel(uri, title,
{
viewColumn: column,
preserveFocus: true
},
{
retainContextWhenHidden,
enableScripts: true
}
));
this._panel.onDidDispose(() => {
this.dispose();
});
Expand Down Expand Up @@ -108,8 +114,9 @@ export class WebviewPanelController implements vscode.Disposable {
this._isDisposed = true;
}

public revealToForeground(): void {
this._panel.reveal();
public revealToForeground(uri: string): void {
let column = this.newResultPaneViewColumn(uri);
this._panel.reveal(column, true);
}

/** Getters */
Expand Down
9 changes: 5 additions & 4 deletions src/models/sqlOutputContentProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,12 @@ export class SqlOutputContentProvider {
await this.runQueryCallback(statusView ? statusView : this._statusView, uri, title,
async (queryRunner) => {
if (queryRunner) {
// if the panel isn't active, bring it to foreground
if (!this._panels.get(uri).isActive) {
this._panels.get(uri).revealToForeground();
// if the panel isn't active and exists
if (this._panels.get(uri).isActive === false) {
this._panels.get(uri).revealToForeground(uri);
}
await queryRunner.runQuery(selection, promise);

}
});
}
Expand Down Expand Up @@ -298,7 +299,7 @@ export class SqlOutputContentProvider {
const queryRunner = this.getQueryRunner(uri);
// in case of a tab switch
// and if it has rendered before
if (panelController.isActive &&
if (panelController.isActive !== undefined &&
queryRunner.hasCompleted &&
panelController.rendered) {
return queryRunner.refreshQueryTab(uri);
Expand Down

0 comments on commit e3d42ca

Please sign in to comment.