Skip to content

Commit

Permalink
improvements to snippet editing and 0.2.0 ready
Browse files Browse the repository at this point in the history
  • Loading branch information
dzsquared committed Sep 7, 2019
1 parent ccf4cdd commit 41a8b71
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 18 deletions.
33 changes: 21 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
}
},
{
Expand Down
13 changes: 11 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}
Expand Down
1 change: 0 additions & 1 deletion src/placescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 41a8b71

Please sign in to comment.