diff --git a/README.md b/README.md index ffd50ed..5a03fcc 100644 --- a/README.md +++ b/README.md @@ -1,53 +1,57 @@ # Azure Data Studio - Query Editor Boost -This extension adds several features helpful with query writing in Azure Data Studio - use database keyboard shortcut, new query window template, and friendly snippet editor. +This extension adds several features helpful with query writing in Azure Data Studio - use database keyboard shortcut, new query template, and friendly snippet editor. ![Query Editor Boost](https://raw.githubusercontent.com/dzsquared/query-editor-boost/master/images/QEboost200.png) ## Installation -The current release is available to [download as a .vsix file](https://github.com/dzsquared/query-editor-boost/releases/download/0.1.0/query-editor-boost-0.1.0.vsix) and can be installed by opening the command palette (`ctrl/command+shift+p`) and selecting `Extensions: Install from VSIX...` +The current release is available to [download as a .vsix file](https://github.com/dzsquared/query-editor-boost/releases/download/0.2.0/query-editor-boost-0.2.0.vsix) and can be installed by opening the command palette (`ctrl/command+shift+p`) and selecting `Extensions: Install from VSIX...` ### Setup: New Query Template -Edit the setting for "New Query Template" in Azure Data Studio settings directly or create a new query template in the editor and run the command "QE Boost: Set New Query Template". +Edit the setting for "New Query Template" by creating a new query template in the editor and running the command "QE Boost: Set New Query Template". This setting can also be updated directly in the Azure Data Studio settings. ### Uninstalling? I'm sad to see you go, but before you uninstall I recommended running the command "QE Boost: Reset Dashboard Shortcuts". This will re-add the original *New Query* button to the server and database dashboards. -## Features +# Features -### New Query from Template -This extension overrides the default "New Query" keyboard shortcut (`ctrl+n`) with a new query window with a query template of your design. Set the query template from Azure Data Studio settings (`ctrl+,`). -*Note: This extension does not override "New Query" in the file menu.* +## New Query from Template +This extension overrides the default "New Query" keyboard shortcut (`ctrl+n`) with a new query window with a query template of your design. Set the query template with the command "QE Boost: Set New Query Template" or from the Azure Data Studio settings (`ctrl+,`). +*Note: This extension does not override "New Query" in the file or object explorer menus.* ![Set and Use New Query Template](https://raw.githubusercontent.com/dzsquared/query-editor-boost/master/images/setNewQueryTemplate.gif) -### Use Database +## Use Database Change the connected database in a query editor with the "QE Boost: Use Database" command (`ctrl+u`), which opens a searchable picklist. Return to the query editor by hitting `Enter` and your hands never leave the keyboard. ![Use Database Shortcut](https://raw.githubusercontent.com/dzsquared/query-editor-boost/master/images/useDatabase.gif) -### Create New Snippets +## Create New Snippets When creating new snippets, move quickly through the syntax and manual JSON editing with friendly snippet creation. Makes writing new snippet queries easier by placing placeholders (tab stops) and supported variables in the editor window. -#### Insert Placeholders +### Insert Placeholders + +Use the command "QE Boost: Add Snippet Placeholder" to add placeholders to your query text. Query Editor Boost will parse repetive use of a placeholder through 99 distinct placeholders. ![Snippet Placeholders](https://raw.githubusercontent.com/dzsquared/query-editor-boost/master/images/snippetPlaceholders.gif) -#### Insert Variables +### Insert Variables + +Use the command "QE Boost: Add Snippet Variable" to add snippet variables to your query text. These variables can automatically insert information such as the current date or directory. ![Snippet Variables](https://raw.githubusercontent.com/dzsquared/query-editor-boost/master/images/snippetVariables.gif) More info on variables: https://code.visualstudio.com/docs/editor/userdefinedsnippets#_creating-your-own-snippets -#### Save the Current Query as a Snippet +### Save the Current Query as a Snippet Write a new snippet in the query editor and save it directly to your local snippet repository with the command "QE Boost: Save New Snippet." Extension for VS Code, licensed under MIT license, adapted for use in this extension. @@ -71,6 +75,11 @@ Can be raised here: https://github.com/dzsquared/query-editor-boost/issues ## Release Notes +### 0.2.0 + +- Fixes to new query from template +- Improvements to snippet placeholder creation + ### 0.1.0 - Initial release diff --git a/package.json b/package.json index 27d05ee..feae94f 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "query-editor-boost", "displayName": "Query Editor Boost", "description": "Helpful add-ons for query editing", - "version": "0.1.0", + "version": "0.2.0", "publisher": "drewsk", "engines": { "vscode": "^1.37.0", @@ -34,8 +34,8 @@ "command": "dsk.newqueryoption", "title": "QE Boost: New Query", "icon": { - "light": "./src/media/newquery.svg", - "dark": "./src/media/newquery-inverse.svg" + "light": "src/media/newquery.svg", + "dark": "src/media/newquery-inverse.svg" } }, { diff --git a/src/extension.ts b/src/extension.ts index 238969d..27b8a04 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -81,8 +81,17 @@ export function activate(context: vscode.ExtensionContext) { let currentQuery:string = editor.document.getText(); while (placeholderIndex == 0) { - if (!(currentQuery.includes('${'+testIndex.toString()) ) ) { - placeholderIndex = testIndex; + if ( currentQuery.includes(':'+newPlaceholder+'}') ) { + let probableindex:string = currentQuery.substr(currentQuery.indexOf(':'+newPlaceholder+'}')-2,2); + if (probableindex[0] == '{') { + placeholderIndex = parseInt(probableindex[1]); + } else { + placeholderIndex = parseInt(probableindex); + } + } else { + if (!(currentQuery.includes('${'+testIndex.toString()) ) ) { + placeholderIndex = testIndex; + } } testIndex++; } diff --git a/src/placescript.ts b/src/placescript.ts index eba06c2..977b1bf 100644 --- a/src/placescript.ts +++ b/src/placescript.ts @@ -12,7 +12,6 @@ export class placeScript { public async placescript(scriptText:string, context?:sqlops.IConnectionProfile, oecontext?: sqlops.ObjectExplorerContext) { try { var connection; - vscode.window.showInformationMessage('starting placescript'); if (context && context.id) { this.connectionId = context.id; this.dbName = context.databaseName;