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:
Enrique Mejia
2021-03-31 10:53:52 -05:00
committed by GitHub
parent cb619f55c7
commit 00d2fadb7d
2 changed files with 7 additions and 2 deletions

View File

@@ -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

View File

@@ -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)
};
}