Skip to content

Commit

Permalink
Check editor statement parameter is valid
Browse files Browse the repository at this point in the history
Signed-off-by: Liam Barry Allan <[email protected]>
  • Loading branch information
worksofliam committed Jul 10, 2022
1 parent d1f55d2 commit 9ed85da
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/language/results/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,18 @@ exports.initialise = (context) => {
* @param {StatementInfo} [options]
*/
async (options) => {
// Options here can be a vscode.Uri when called from editor context.
// But that isn't valid here.
const optionsIsValid = (options && options.content !== undefined);

const instance = getInstance();
const config = instance.getConfig();
const content = instance.getContent();
const editor = vscode.window.activeTextEditor;

if (options || (editor && editor.document.languageId === `sql`)) {
if (optionsIsValid || (editor && editor.document.languageId === `sql`)) {
/** @type {StatementInfo} */
const statement = options || this.parseStatement(editor);
const statement = (optionsIsValid ? options : this.parseStatement(editor));

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

0 comments on commit 9ed85da

Please sign in to comment.