mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-23 17:23:02 -05:00
Use {arg} to reference selected text in query shortcuts (#14894)
* Add selection parameter to query shortcuts
* Add description for selected text as parameter
* Modify feature description since it supports proceedures and queries
* Replace every {arg} inside query shortcut
This commit is contained in:
@@ -380,7 +380,12 @@ export class RunQueryShortcutAction extends Action {
|
||||
// otherwise, either run the statement or the script depending on parameter
|
||||
let parameterText: string = editor.getSelectionText();
|
||||
return this.escapeStringParamIfNeeded(editor, shortcutText, parameterText).then((escapedParam) => {
|
||||
let queryString = `${shortcutText} ${escapedParam}`;
|
||||
let queryString = '';
|
||||
if (shortcutText.includes('{arg}')) {
|
||||
queryString = shortcutText.replace(/{arg}/g, escapedParam);
|
||||
} else {
|
||||
queryString = `${shortcutText} ${escapedParam}`;
|
||||
}
|
||||
editor.input.runQueryString(queryString);
|
||||
}).then(success => null, err => {
|
||||
// swallow errors for now
|
||||
|
||||
@@ -468,7 +468,7 @@ for (let i = 0; i < 9; i++) {
|
||||
'type': 'string',
|
||||
'default': defaultVal,
|
||||
'description': localize('queryShortcutDescription',
|
||||
"Set keybinding workbench.action.query.shortcut{0} to run the shortcut text as a procedure call. Any selected text in the query editor will be passed as a parameter",
|
||||
"Set keybinding workbench.action.query.shortcut{0} to run the shortcut text as a procedure call or query execution. Any selected text in the query editor will be passed as a parameter at the end of your query, or you can reference it with {arg}",
|
||||
queryIndex)
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user