mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Simplify connection checks in RunQueryAction (#17018)
This commit is contained in:
@@ -206,11 +206,8 @@ export class RunQueryAction extends QueryTaskbarAction {
|
|||||||
|
|
||||||
public override async run(): Promise<void> {
|
public override async run(): Promise<void> {
|
||||||
if (!this.editor.isSelectionEmpty()) {
|
if (!this.editor.isSelectionEmpty()) {
|
||||||
await this.connectionManagementService.refreshAzureAccountTokenIfNecessary(this.editor.input.uri);
|
const runQueryResult = await this.runQuery(this.editor);
|
||||||
if (this.isConnected(this.editor)) {
|
if (!runQueryResult) {
|
||||||
// If we are already connected, run the query
|
|
||||||
this.runQuery(this.editor);
|
|
||||||
} else {
|
|
||||||
// If we are not already connected, prompt for connection and run the query if the
|
// If we are not already connected, prompt for connection and run the query if the
|
||||||
// connection succeeds. "runQueryOnCompletion=true" will cause the query to run after connection
|
// connection succeeds. "runQueryOnCompletion=true" will cause the query to run after connection
|
||||||
this.connectEditor(this.editor, RunQueryOnConnectionMode.executeQuery, this.editor.getSelection());
|
this.connectEditor(this.editor, RunQueryOnConnectionMode.executeQuery, this.editor.getSelection());
|
||||||
@@ -221,11 +218,8 @@ export class RunQueryAction extends QueryTaskbarAction {
|
|||||||
|
|
||||||
public async runCurrent(): Promise<void> {
|
public async runCurrent(): Promise<void> {
|
||||||
if (!this.editor.isSelectionEmpty()) {
|
if (!this.editor.isSelectionEmpty()) {
|
||||||
await this.connectionManagementService.refreshAzureAccountTokenIfNecessary(this.editor.input.uri);
|
const runQueryResult = await this.runQuery(this.editor, true);
|
||||||
if (this.isConnected(this.editor)) {
|
if (!runQueryResult) {
|
||||||
// If we are already connected, run the query
|
|
||||||
this.runQuery(this.editor, true);
|
|
||||||
} else {
|
|
||||||
// If we are not already connected, prompt for connection and run the query if the
|
// If we are not already connected, prompt for connection and run the query if the
|
||||||
// connection succeeds. "runQueryOnCompletion=true" will cause the query to run after connection
|
// connection succeeds. "runQueryOnCompletion=true" will cause the query to run after connection
|
||||||
this.connectEditor(this.editor, RunQueryOnConnectionMode.executeCurrentQuery, this.editor.getSelection(false));
|
this.connectEditor(this.editor, RunQueryOnConnectionMode.executeCurrentQuery, this.editor.getSelection(false));
|
||||||
@@ -234,11 +228,12 @@ export class RunQueryAction extends QueryTaskbarAction {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
public runQuery(editor: QueryEditor, runCurrentStatement: boolean = false) {
|
private async runQuery(editor: QueryEditor, runCurrentStatement: boolean = false): Promise<boolean> {
|
||||||
if (!editor) {
|
if (!editor) {
|
||||||
editor = this.editor;
|
editor = this.editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await this.connectionManagementService.refreshAzureAccountTokenIfNecessary(this.editor.input.uri);
|
||||||
if (this.isConnected(editor)) {
|
if (this.isConnected(editor)) {
|
||||||
// Hide IntelliSense suggestions list when running query to match SSMS behavior
|
// Hide IntelliSense suggestions list when running query to match SSMS behavior
|
||||||
this.commandService?.executeCommand('hideSuggestWidget');
|
this.commandService?.executeCommand('hideSuggestWidget');
|
||||||
@@ -252,7 +247,9 @@ export class RunQueryAction extends QueryTaskbarAction {
|
|||||||
selection = editor.getSelection();
|
selection = editor.getSelection();
|
||||||
editor.input.runQuery(selection);
|
editor.input.runQuery(selection);
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected isCursorPosition(selection: IRange) {
|
protected isCursorPosition(selection: IRange) {
|
||||||
|
|||||||
Reference in New Issue
Block a user