Skip to content

Commit

Permalink
Fix duplicate macros in the completion.
Browse files Browse the repository at this point in the history
  • Loading branch information
moetelo committed Jul 24, 2024
1 parent 926d2cb commit 242d0b7
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/language-server/src/completions/variableProperties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,20 +111,22 @@ export async function variableProperties(

const importedDocument = await documentCache.resolveImport(document, variableName, pos);
if (importedDocument) {
const localMacros = importedDocument.locals.macro.map(macroToCompletionItem);
const localMacros = importedDocument.locals.macro;

if (importedDocument !== document) {
return localMacros;
return localMacros.map(macroToCompletionItem);
}

const scopedMacros = importedDocument
.getScopeAt(pointToPosition(cursorNode.startPosition))
?.macro.map(macroToCompletionItem) || [];
?.macro || [];

return [
const allMacros = new Set([
...localMacros,
...scopedMacros,
];
]);

return [...allMacros].map(macroToCompletionItem);
}

return [];
Expand Down

0 comments on commit 242d0b7

Please sign in to comment.