Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renaming a file does not update imports #3646

Closed
andraaspar opened this issue Oct 9, 2023 · 2 comments
Closed

Renaming a file does not update imports #3646

andraaspar opened this issue Oct 9, 2023 · 2 comments
Labels
bug Something isn't working good reproduction ✨ This issue provides a good reproduction, we will be able to investigate it first

Comments

@andraaspar
Copy link

Repo: https://github.com/andraaspar/vue-lang-tools-rename-issue

VS Code 1.83.0

The only extensions installed are:

  1. TypeScript Vue Plugin (Volar) v1.8.18
  2. Vue Language Features (Volar) v1.8.18

I have created a new project using yarn create vue and answered Yes only to TypeScript.

I have the following 3 files:

renameMe.ts

export function renameMe() {
  return 'Hello World!'
}

ThenCheckMe.vue

<script setup lang="ts">
import { renameMe } from './renameMe';
</script>

<template>
  {{renameMe()}}
</template>

thenCheckMeToo.ts

import { renameMe } from './renameMe';

export function thenCheckMeToo() {
  return renameMe()
}

I right click renameMe.ts and select Rename..., and make it renameMe2.ts.

If TypeScript and JavaScript Language Features is enabled

ThenCheckMe.vue becomes:

<script setup lang="ts">
import { renameMe } from './renameMe';

</script>

<template>
  {{renameMe()}}
</template>./renameMe2

❌ Note the import did not change, but the new file name was appended to the final line.

thenCheckMeToo.ts becomes:

import { renameMe } from './renameMe2';

export function thenCheckMeToo() {
  return renameMe()
}

✅ This is correct.

If TypeScript and JavaScript Language Features is disabled (takeover mode)

ThenCheckMe.vue becomes:

<script setup lang="ts">
import { renameMe } from './renameMe';

</script>

<template>
  {{renameMe()}}
</template>

❌ Note the import did not change.

thenCheckMeToo.ts becomes:

import { renameMe } from './renameMe';

export function thenCheckMeToo() {
  return renameMe()
}

❌ Note the import did not change.

@mor-o
Copy link

mor-o commented Feb 17, 2024

Still an issue

@johnsoncodehk johnsoncodehk added bug Something isn't working good reproduction ✨ This issue provides a good reproduction, we will be able to investigate it first labels Mar 26, 2024
@johnsoncodehk
Copy link
Member

For the first case fixed by volarjs/volar.js@d4fbbd7.

The second case may be due to your vue.updateImportsOnFileMove.enabled setting not being enabled, which will be enabled by default in the next version.

Thanks for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good reproduction ✨ This issue provides a good reproduction, we will be able to investigate it first
Projects
None yet
Development

No branches or pull requests

3 participants