From 75e8b6c03592fefe88e84d819b4b3259f81aa9ad Mon Sep 17 00:00:00 2001 From: Dan Pollak Date: Tue, 10 Jan 2023 19:09:19 -0600 Subject: [PATCH] Ignore undefined regex results --- src/ai_completion.js | 4 ++-- src/ai_workspaceSymbols.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ai_completion.js b/src/ai_completion.js index 36593d9..1adc3c0 100644 --- a/src/ai_completion.js +++ b/src/ai_completion.js @@ -89,8 +89,8 @@ const getVariableCompletions = (text, firstChar) => { if (firstChar === '$') { let pattern = variablePattern.exec(text); while (pattern) { - [variableName] = pattern; - if (!(variableName in foundVariables)) { + [, variableName] = pattern; + if (variableName !== undefined && !(variableName in foundVariables)) { foundVariables[variableName] = true; variables.push(createNewCompletionItem(CompletionItemKind.Variable, variableName)); } diff --git a/src/ai_workspaceSymbols.js b/src/ai_workspaceSymbols.js index ea24c59..84e8eef 100644 --- a/src/ai_workspaceSymbols.js +++ b/src/ai_workspaceSymbols.js @@ -40,7 +40,7 @@ function provideWorkspaceSymbols(query) { const { 1: newName } = variableFound; // Filter based on search (if it's not empty) - if (!searchFilter.exec(newName)) { + if (newName === undefined || !searchFilter.exec(newName)) { return false; } symbolKind = SymbolKind.Variable;