Skip to content

Commit d1e7568

Browse files
committed
fix(language-core): global component rename locations missing end tag
1 parent 7928a2d commit d1e7568

File tree

2 files changed

+95
-0
lines changed

2 files changed

+95
-0
lines changed

packages/language-core/lib/codegen/template/element.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,14 @@ export function* generateComponent(
143143
yield ` | typeof ${names.components}.`;
144144
yield* generateCamelized(capitalize(tag), 'template', startTagOffset, codeFeatures.navigation);
145145
}
146+
if (endTagOffset !== undefined) {
147+
yield ` | typeof ${names.components}.`;
148+
yield* generateCamelized(tag, 'template', endTagOffset, codeFeatures.navigation);
149+
if (tag[0] !== tag[0]!.toUpperCase()) {
150+
yield ` | typeof ${names.components}.`;
151+
yield* generateCamelized(capitalize(tag), 'template', endTagOffset, codeFeatures.navigation);
152+
}
153+
}
146154
yield `} */${newLine}`;
147155
// auto import support
148156
yield* generateCamelized(tag, 'template', startTagOffset, codeFeatures.importCompletionOnly);

packages/language-server/tests/renaming.spec.ts

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,93 @@ test('Component tags', async () => {
905905
`);
906906
});
907907

908+
test('Global component tags', async () => {
909+
expect(
910+
await requestRenameToTsServer(
911+
'tsconfigProject/fixture.vue',
912+
'vue',
913+
`
914+
<script lang="ts" setup>
915+
declare module 'vue' {
916+
export interface GlobalComponents {
917+
Foo|: any;
918+
}
919+
}
920+
</script>
921+
922+
<template>
923+
<Foo></Foo>
924+
</template>
925+
`,
926+
),
927+
).toMatchInlineSnapshot(`
928+
{
929+
"info": {
930+
"canRename": true,
931+
"displayName": "Foo",
932+
"fullDisplayName": ""vue".GlobalComponents.Foo",
933+
"kind": "property",
934+
"kindModifiers": "declare",
935+
"triggerSpan": {
936+
"end": {
937+
"line": 5,
938+
"offset": 9,
939+
},
940+
"start": {
941+
"line": 5,
942+
"offset": 6,
943+
},
944+
},
945+
},
946+
"locs": [
947+
{
948+
"file": "\${testWorkspacePath}/tsconfigProject/fixture.vue",
949+
"locs": [
950+
{
951+
"end": {
952+
"line": 11,
953+
"offset": 15,
954+
},
955+
"start": {
956+
"line": 11,
957+
"offset": 12,
958+
},
959+
},
960+
{
961+
"end": {
962+
"line": 11,
963+
"offset": 9,
964+
},
965+
"start": {
966+
"line": 11,
967+
"offset": 6,
968+
},
969+
},
970+
{
971+
"contextEnd": {
972+
"line": 5,
973+
"offset": 15,
974+
},
975+
"contextStart": {
976+
"line": 5,
977+
"offset": 6,
978+
},
979+
"end": {
980+
"line": 5,
981+
"offset": 9,
982+
},
983+
"start": {
984+
"line": 5,
985+
"offset": 6,
986+
},
987+
},
988+
],
989+
},
990+
],
991+
}
992+
`);
993+
});
994+
908995
test('#4673', async () => {
909996
expect(
910997
await requestRenameToTsServer(

0 commit comments

Comments
 (0)