Skip to content

Commit 0c04048

Browse files
committed
fix autocomplete for $props.id()
1 parent b032bbd commit 0c04048

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

packages/site-kit/src/lib/codemirror/autocompletionDataProvider.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -576,18 +576,26 @@ const is_bindable = (node, context) => {
576576
/**
577577
* @type {import("./types").Test}
578578
*/
579-
const is_props_id = (node) => {
580-
if (node.parent?.name !== 'VariableDeclaration') return false;
581-
if (node.parent?.parent?.name !== 'VariableDeclarator') return false;
582-
if (node.parent?.parent?.parent?.name !== 'Program') return false;
583-
if (node.parent?.firstChild?.name !== 'Identifier') return false;
579+
const is_props_id_call = (node, context, selected) => {
580+
if (!is_state_call(node, context, selected)) return false;
581+
if (node.parent?.parent?.name !== 'Script') return false;
584582
return true;
585-
};
583+
}
584+
585+
/**
586+
* @type {import("./types").Test}
587+
*/
588+
const is_props_id = (node, context, selected) => {
589+
if (!is_state(node, context, selected)) return false;
590+
if (node.parent?.parent?.name !== 'Script') return false;
591+
return true;
592+
}
586593

587594
export const runes = [
588595
{ snippet: '$state(${})', test: is_state },
589596
{ snippet: '$state', test: is_state_call },
590597
{ snippet: '$props()', test: is_props },
598+
{ snippet: '$props.id', test: is_props_id_call },
591599
{ snippet: '$props.id()', test: is_props_id },
592600
{ snippet: '$derived(${});', test: is_state },
593601
{ snippet: '$derived', test: is_state_call },

0 commit comments

Comments
 (0)