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

The effect of renaming variables in <template> is unpredictable #4297

Closed
KazariEX opened this issue Apr 24, 2024 · 6 comments
Closed

The effect of renaming variables in <template> is unpredictable #4297

KazariEX opened this issue Apr 24, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@KazariEX
Copy link

KazariEX commented Apr 24, 2024

仅限 Hybrid Mode 模式。

1. 所有直接来自 <script> 的变量,均无法在光标位于起始位置时重命名;在其余位置的重命名不会产生任何效果。

image

image

2. 在 v-if 中,从变量的第 2 个字符开始,到 v-if 所在元素的标签名长度个字符后的位置对变量重命名,它将对所有该标签名的元素进行重命名,并原地打开 runtime-dom.d.ts 篡改类型定义;而在上述字符范围外的重命名不会产生任何效果。

v-for 中则是从被遍历对象的倒数第 5 个字符开始,到标签名长度 +2 个字符后的位置

image

image

image

3. 在 v-for 中,从索引变量的最后一个字符往前推移 12 个字符,到被遍历对象的变量名长度个字符后的位置,如果范围内存在变量,则此时的重命名将对被遍历对象本身生效,除此之外在其余位置的重命名不会产生任何效果。

image

image

image

@johnsoncodehk johnsoncodehk added the bug Something isn't working label Apr 27, 2024
@johnsoncodehk
Copy link
Member

johnsoncodehk commented Apr 27, 2024

  1. 所有直接来自 <script> 的变量,均无法在光标位于起始位置时重命名

我只能復現這個問題,其他復現不了。你能提供重現項目嗎?

@KazariEX
Copy link
Author

https://github.com/KazariEX/vue-rename-demo

我禁用了除 Vue - Offical 外的所有插件,并重新安装了依赖,问题依然生效

另外我想知道 vue playground 是基于什么方式实现的,在上面并不能复现包括这个 issue 在内的很多问题

@johnsoncodehk
Copy link
Member

johnsoncodehk commented Apr 27, 2024

我復現那個問題由 volarjs/volar.js@803c2b3 解決了。

其他問題我還是復現不了,你用 GitHub Codespaces 打開 https://github.com/KazariEX/vue-rename-demo 可以復現嗎?

另外我想知道 vue playground 是基于什么方式实现的,在上面并不能复现包括这个 issue 在内的很多问题

vue playground 還沒有升級 2.0,以及不是基於 Hybrid Mode 的。

@KazariEX
Copy link
Author

GitHub Codespaces 无法复现,但是我本地测试时禁用了其他插件,应该不会有影响才是。目前只能选择先关闭 Hybrid Mode

@johnsoncodehk
Copy link
Member

你能讓我遠程看嗎?可以的話請在 https://discord.gg/vue 的 #language-tools channel ping 我。

@johnsoncodehk
Copy link
Member

Fixed by volarjs/volar.js@233cb15.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants