Skip to content

Commit 5b93787

Browse files
committed
Fix undefined in completion tooltip
Resolves #19
1 parent edccad2 commit 5b93787

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ CHANGELOG
55
---
66

77
* Lint right-side argument type for `in` operator
8+
* Fix `undefined` in completion keyword tooltip (#19)
89

910
1.0
1011
---

src/complete.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ const autocompleteFunction = (x: ELFunction): Completion => ({
3737
);
3838
},
3939
detail: x.returnType?.join('|'),
40-
info: () => ({ dom: createCompletionInfoElement(x.info) }),
40+
info: () => createCompletionInfoElement(x.info),
4141
type: "function",
4242
});
4343
const autocompleteIdentifier = (x: ELIdentifier): Completion => ({
4444
label: x.name,
4545
apply: x.name,
46-
info: () => ({ dom: createCompletionInfoElement(x.info) }),
46+
info: () => createCompletionInfoElement(x.info),
4747
detail: x.detail || x.type?.join('|'),
4848
type: 'variable',
4949
});
@@ -55,7 +55,7 @@ function completeOperatorKeyword(state: EditorState, config: ExpressionLanguageC
5555
options: keywords.map(({ name, info, detail }) => ({
5656
label: name,
5757
apply: `${name} `,
58-
info: () => ({ dom: createCompletionInfoElement(info) }),
58+
info: () => createCompletionInfoElement(info),
5959
detail,
6060
type: "keyword"
6161
})) ?? [],

src/utils.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,13 @@ export const createInfoElement = (html: string) => {
2424
};
2525

2626
export const createCompletionInfoElement = (html: string) => {
27+
if (!html) {
28+
return undefined;
29+
}
30+
2731
const dom = document.createElement("div")
2832
dom.innerHTML = html;
29-
return dom;
33+
return { dom };
3034
};
3135

3236
export function resolveFunctionDefinition(node: SyntaxNode | null, state: EditorState, config: ExpressionLanguageConfig) {

0 commit comments

Comments
 (0)