Skip to content

Commit

Permalink
test: add renaming case for template ref() (#4794)
Browse files Browse the repository at this point in the history
  • Loading branch information
KazariEX authored Sep 3, 2024
1 parent bdf5d41 commit b9d5f9c
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/language-core/lib/codegen/template/element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ function* generateReferencesForElements(
) {
const [content, startOffset] = normalizeAttributeValue(prop.value);

yield `// @ts-ignore${newLine}`;
yield `// @ts-ignore navigation for \`const ${content} = ref()\`${newLine}`;
yield `__VLS_ctx`;
yield* generatePropertyAccess(
options,
Expand Down
48 changes: 48 additions & 0 deletions packages/language-server/tests/renaming.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,54 @@ describe('Renaming', async () => {
`);
});

it('Ref', async () => {
expect(
await requestRename('tsconfigProject/fixture.vue', 'vue', `
<template>
<a ref="foo"></a>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
const foo| = ref();
</script>
`, 'bar')
).toMatchInlineSnapshot(`
{
"changes": {
"file://\${testWorkspacePath}/tsconfigProject/fixture.vue": [
{
"newText": "bar",
"range": {
"end": {
"character": 16,
"line": 2,
},
"start": {
"character": 13,
"line": 2,
},
},
},
{
"newText": "bar",
"range": {
"end": {
"character": 13,
"line": 7,
},
"start": {
"character": 10,
"line": 7,
},
},
},
],
},
}
`);
});

it('Template Ref', async () => {
expect(
await requestRename('tsconfigProject/fixture.vue', 'vue', `
Expand Down

0 comments on commit b9d5f9c

Please sign in to comment.