From 526ce7452781e592cb0d59433fad6f631bb8c8bc Mon Sep 17 00:00:00 2001 From: zhiyuanzmj <32807958+zhiyuanzmj@users.noreply.github.com> Date: Sat, 21 Dec 2024 05:13:16 +0800 Subject: [PATCH] fix(language-core): prevent visiting functional components for parseScriptSetupRanges (#5049) --- .../language-core/lib/parsers/scriptSetupRanges.ts | 3 +++ .../tsc/passedFixtures/vue3/templateRef/main.vue | 11 ++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/language-core/lib/parsers/scriptSetupRanges.ts b/packages/language-core/lib/parsers/scriptSetupRanges.ts index d8f4705a66..0eebc5071e 100644 --- a/packages/language-core/lib/parsers/scriptSetupRanges.ts +++ b/packages/language-core/lib/parsers/scriptSetupRanges.ts @@ -396,6 +396,9 @@ export function parseScriptSetupRanges( } ts.forEachChild(node, child => { + if (ts.isFunctionLike(node)) { + return; + } parents.push(node); visitNode(child, parents); parents.pop(); diff --git a/test-workspace/tsc/passedFixtures/vue3/templateRef/main.vue b/test-workspace/tsc/passedFixtures/vue3/templateRef/main.vue index 71237e3276..50c8109f39 100644 --- a/test-workspace/tsc/passedFixtures/vue3/templateRef/main.vue +++ b/test-workspace/tsc/passedFixtures/vue3/templateRef/main.vue @@ -1,10 +1,19 @@