From 826d4c287917d2e4d851cf3b427e4aad4e7daa1f Mon Sep 17 00:00:00 2001 From: Drew Skwiers-Koballa Date: Sun, 16 Feb 2020 20:48:21 -0600 Subject: [PATCH] removing editor connection helper for file saves --- src/connectHolder.ts | 36 ------------------------------------ src/extension.ts | 5 ----- src/queryEditorHelper.ts | 15 --------------- 3 files changed, 56 deletions(-) delete mode 100644 src/connectHolder.ts delete mode 100644 src/queryEditorHelper.ts diff --git a/src/connectHolder.ts b/src/connectHolder.ts deleted file mode 100644 index 959afd2..0000000 --- a/src/connectHolder.ts +++ /dev/null @@ -1,36 +0,0 @@ -'use strict'; - -import * as azdata from 'azdata'; -import * as vscode from 'vscode'; - - - export async function hangOnToConnection(): Promise { - let connectProf = await azdata.connection.getCurrentConnection(); - let connectHoldId : string = ''; - let dbName: string = ''; - let providerId: string = ''; - connectHoldId = connectProf.connectionId; - dbName = connectProf.databaseName; - providerId = connectProf.providerId; - - return {connectHoldId: connectHoldId, dbName: dbName, providerId: providerId}; - } - - export async function utilizeConnection(doc: vscode.TextDocument, actualConnectionInfo: actualConnectionInfo) { - if ( actualConnectionInfo.connectHoldId ) { - if (actualConnectionInfo.dbName !== '') { - let dProvider = await azdata.dataprotocol.getProvider(actualConnectionInfo.providerId, azdata.DataProviderType.ConnectionProvider); - let connectionUri = await azdata.connection.getUriForConnection(actualConnectionInfo.connectHoldId); - await dProvider.changeDatabase(connectionUri,actualConnectionInfo.dbName); - await azdata.queryeditor.connect(doc.uri.toString(), actualConnectionInfo.connectHoldId); - } - } - - } - - - export class actualConnectionInfo { - connectHoldId: string; - dbName: string; - providerId: string; - } \ No newline at end of file diff --git a/src/extension.ts b/src/extension.ts index 56b99e6..01000e4 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -5,7 +5,6 @@ import * as azdata from 'azdata'; import { changeDatabase } from './changeDatabase'; import { initQEB } from './settingsUpdates'; import { setEagerRunContext } from './contextSettings'; -import { willSaveQuery, querySaved } from './queryEditorHelper'; import { addSnippetPlaceholder, addSnippetVariable, saveNewSnippet } from './snippetHelper'; import { runQuerySection } from './runQuery'; @@ -20,10 +19,6 @@ export function activate(context: vscode.ExtensionContext) { setEagerRunContext(); context.subscriptions.push(vscode.workspace.onDidChangeConfiguration(setEagerRunContext)); - // patches text editor save and query connection - context.subscriptions.push(vscode.workspace.onWillSaveTextDocument( (willSave: vscode.TextDocumentWillSaveEvent) => willSaveQuery(willSave) )); - context.subscriptions.push(vscode.workspace.onDidSaveTextDocument( (doc: vscode.TextDocument) => querySaved(doc) )); - // telemetry setup var tH = new telemetryHelper(context); tH.sendTelemetry('activated', { }, { }); diff --git a/src/queryEditorHelper.ts b/src/queryEditorHelper.ts deleted file mode 100644 index ab2309d..0000000 --- a/src/queryEditorHelper.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { actualConnectionInfo, hangOnToConnection, utilizeConnection } from './connectHolder'; -import * as vscode from 'vscode'; - -var connectionInfo: actualConnectionInfo; - -export async function willSaveQuery(willSave: vscode.TextDocumentWillSaveEvent) { - if (willSave.document.uri.scheme == "file") { - connectionInfo = await hangOnToConnection(); - } -} -export async function querySaved(doc: vscode.TextDocument) { - if (doc.uri.scheme == "file") { - await utilizeConnection(doc, connectionInfo); - } -}