vuejs / language-tools

⚡ High-performance Vue language tooling based-on Volar.js
https://marketplace.visualstudio.com/items?itemName=Vue.volar
MIT License
5.55k stars 373 forks source link

const syntax highlighting fails if the const is scrolled too far out of view #4464

Open cdrez opened 2 weeks ago

cdrez commented 2 weeks ago

Vue - Official extension or vue-tsc version

2.0.21

VSCode version

1.90.0

Vue version

3.4.27

TypeScript version

5.4.5

System Info

No response

Steps to reproduce

Installed Extensions: Vue - Official

Create a new vue file with a const. The const is properly highlighted if the scroll port is within a certain distance to the const declaration. However, if the scroll port is too far away from the declaration, the variable's syntax highlighting is no longer the same.

This depends on your zoom level as well, but if you get it in the sweet spot, you can watch the syntax highlighting flip on and off for that variable as you scroll up and down.

I also noticed that if I add a comment above the foo.value = "bar2" line, the syntax highlighting returns to the variable.

I also tested the behavior on Vue - Official v1.8.27 and it worked as expected there. It was broken on every version of v2 that I tried.

Probably related to #3934 and #3935.

Screen Recording

<script setup lang="ts">
import { ref } from 'vue';

const foo = ref();

foo.value = "bar";

foo.value = "bar2"
</script>

Link to minimal reproduction

No response

Any additional comments?

No response

vusal5555 commented 1 week ago

That is exactly the issue I have been facing for a week now. It also fails to highlight components imported in another components and HTML elements within named slots as well.

cdrez commented 1 week ago

My guess about it being based on how far you scroll passed the variable definition was wrong. I get the same issue on variables defined in the middle of the file, can scroll up and down and watch the highlighting disable and re-enable repeatedly. So I'm not sure what the cause is since scroll position and text (a comment) above the line seem to both affect it.