Skip to content

Commit 9ed85da

Browse files
committed
Check editor statement parameter is valid
Signed-off-by: Liam Barry Allan <[email protected]>
1 parent d1f55d2 commit 9ed85da

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/language/results/index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,18 @@ exports.initialise = (context) => {
119119
* @param {StatementInfo} [options]
120120
*/
121121
async (options) => {
122+
// Options here can be a vscode.Uri when called from editor context.
123+
// But that isn't valid here.
124+
const optionsIsValid = (options && options.content !== undefined);
125+
122126
const instance = getInstance();
123127
const config = instance.getConfig();
124128
const content = instance.getContent();
125129
const editor = vscode.window.activeTextEditor;
126130

127-
if (options || (editor && editor.document.languageId === `sql`)) {
131+
if (optionsIsValid || (editor && editor.document.languageId === `sql`)) {
128132
/** @type {StatementInfo} */
129-
const statement = options || this.parseStatement(editor);
133+
const statement = (optionsIsValid ? options : this.parseStatement(editor));
130134

131135
if (statement.open) {
132136
const textDoc = await vscode.workspace.openTextDocument({language: `sql`, content: statement.content});

0 commit comments

Comments
 (0)