vuejs / language-tools

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

Cannot jump to symbol because `untitled.vue` is in uri of `textDocument/documentSymbol` #1925

Closed yaegassy closed 1 year ago

yaegassy commented 1 year ago

Description

VSCode seems to work with untitled.vue, but there is a problem because other editors recognize it as a non-existent file.

By the way, it seems that only blocks such as script setup, templete, style scoped, etc. have the correct uri set.

This untitled.vue seems to have occurred since volar "v0.38.4".

Capture

volar-textdocument-documentsymbol-issue

LOG

Trace Log ``` [Trace - 9:31:43] Received response 'textDocument/documentSymbol - (60)' in 2ms. Result: [ { "name": "header", "location": { "uri": "file:///untitled.vue", "range": { "start": { "line": 7, "character": 2 }, "end": { "line": 24, "character": 11 } } }, "containerName": "", "kind": 8 }, { "name": "img.logo", "location": { "uri": "file:///untitled.vue", "range": { "start": { "line": 8, "character": 4 }, "end": { "line": 14, "character": 6 } } }, "containerName": "header", "kind": 8 }, { "name": "div.wrapper", "location": { "uri": "file:///untitled.vue", "range": { "start": { "line": 16, "character": 4 }, "end": { "line": 23, "character": 10 } } }, "containerName": "header", "kind": 8 }, { "name": "HelloWorld", "location": { "uri": "file:///untitled.vue", "range": { "start": { "line": 17, "character": 6 }, "end": { "line": 17, "character": 38 } } }, "containerName": "div.wrapper", "kind": 8 }, { "name": "nav", "location": { "uri": "file:///untitled.vue", "range": { "start": { "line": 19, "character": 6 }, "end": { "line": 22, "character": 12 } } }, "containerName": "div.wrapper", "kind": 8 }, { "name": "RouterLink", "location": { "uri": "file:///untitled.vue", "range": { "start": { "line": 20, "character": 8 }, "end": { "line": 20, "character": 44 } } }, "containerName": "nav", "kind": 8 }, { "name": "RouterLink", "location": { "uri": "file:///untitled.vue", "range": { "start": { "line": 21, "character": 8 }, "end": { "line": 21, "character": 50 } } }, "containerName": "nav", "kind": 8 }, { "name": "RouterView", "location": { "uri": "file:///untitled.vue", "range": { "start": { "line": 26, "character": 2 }, "end": { "line": 26, "character": 16 } } }, "containerName": "", "kind": 8 }, { "name": "dummy", "kind": 13, "location": { "uri": "file:///untitled.vue", "range": { "start": { "line": 3, "character": 6 }, "end": { "line": 3, "character": 16 } } } }, { "name": "header", "kind": 5, "location": { "uri": "file:///untitled.vue", "range": { "start": { "line": 30, "character": 0 }, "end": { "line": 33, "character": 1 } } } }, { "name": ".logo", "kind": 5, "location": { "uri": "file:///untitled.vue", "range": { "start": { "line": 35, "character": 0 }, "end": { "line": 38, "character": 1 } } } }, { "name": "nav", "kind": 5, "location": { "uri": "file:///untitled.vue", "range": { "start": { "line": 40, "character": 0 }, "end": { "line": 45, "character": 1 } } } }, { "name": "nav a.router-link-exact-active", "kind": 5, "location": { "uri": "file:///untitled.vue", "range": { "start": { "line": 47, "character": 0 }, "end": { "line": 49, "character": 1 } } } }, { "name": "nav a.router-link-exact-active:hover", "kind": 5, "location": { "uri": "file:///untitled.vue", "range": { "start": { "line": 51, "character": 0 }, "end": { "line": 53, "character": 1 } } } }, { "name": "nav a", "kind": 5, "location": { "uri": "file:///untitled.vue", "range": { "start": { "line": 55, "character": 0 }, "end": { "line": 59, "character": 1 } } } }, { "name": "nav a:first-of-type", "kind": 5, "location": { "uri": "file:///untitled.vue", "range": { "start": { "line": 61, "character": 0 }, "end": { "line": 63, "character": 1 } } } }, { "name": "@media (min-width: 1024px)", "kind": 2, "location": { "uri": "file:///untitled.vue", "range": { "start": { "line": 65, "character": 0 }, "end": { "line": 90, "character": 1 } } } }, { "name": "header", "kind": 5, "location": { "uri": "file:///untitled.vue", "range": { "start": { "line": 66, "character": 2 }, "end": { "line": 70, "character": 3 } } } }, { "name": ".logo", "kind": 5, "location": { "uri": "file:///untitled.vue", "range": { "start": { "line": 72, "character": 2 }, "end": { "line": 74, "character": 3 } } } }, { "name": "header .wrapper", "kind": 5, "location": { "uri": "file:///untitled.vue", "range": { "start": { "line": 76, "character": 2 }, "end": { "line": 80, "character": 3 } } } }, { "name": "nav", "kind": 5, "location": { "uri": "file:///untitled.vue", "range": { "start": { "line": 82, "character": 2 }, "end": { "line": 89, "character": 3 } } } }, { "name": "template", "kind": 2, "location": { "uri": "file:///Users/yaegassy/sandbox/check-volar-vite3/src/App.vue", "range": { "start": { "line": 6, "character": 10 }, "end": { "line": 27, "character": 0 } } } }, { "name": "script setup", "kind": 2, "location": { "uri": "file:///Users/yaegassy/sandbox/check-volar-vite3/src/App.vue", "range": { "start": { "line": 0, "character": 24 }, "end": { "line": 4, "character": 0 } } } }, { "name": "style scoped", "kind": 2, "location": { "uri": "file:///Users/yaegassy/sandbox/check-volar-vite3/src/App.vue", "range": { "start": { "line": 29, "character": 14 }, "end": { "line": 91, "character": 0 } } } } ] ```
yaegassy commented 1 year ago

Thanks for the fix and adjustment.

There seems to be a difference between v1.0.0-beta.6 of @volar/vue-language-server published in npm and the server in v1.0.0-beta.6 vsix.

I tried starting the v1.0.0-beta.6 vsix's server with coc-volar and was able to confirm that the problem is fixed.

However, in v1.0.0-beta.6 published on npm, it remained untitled.


Edit:

We will check the behavior again at the next release, so please release it at johnsoncodehk timing.

johnsoncodehk commented 1 year ago

@yaegassy thanks for let me know. I'm just re-publishing it to beta.7 now for avoid causing more problems.

yaegassy commented 1 year ago

@johnsoncodehk Thanks for the quick response. However, it seems that even 1.0.0-beta.7 is not working.

The output of the upgrade is shown below for reference. It appears that some of the dependent packages are 1.0.0-beta.4. e.g. @volar/language-server@1.0.0-beta.4

$ yarn upgrade @volar/vue-language-server@1.0.0-beta.7 @volar/shared@1.0.0-beta.7
yarn upgrade v1.22.19
[1/5] 🔍  Validating package.json...
warning @yaegassy/coc-volar@0.24.10: The engine "coc" appears to be invalid.
[2/5] 🔍  Resolving packages...
[3/5] 🚚  Fetching packages...
[4/5] 🔗  Linking dependencies...
warning " > coc.nvim@0.0.81" has incorrect peer dependency "@types/node@^12.12.0".
[5/5] 🔨  Rebuilding all packages...
success Saved lockfile.
success Saved 12 new dependencies.
info Direct dependencies
├─ @volar/shared@1.0.0-beta.7
└─ @volar/vue-language-server@1.0.0-beta.7
info All dependencies
├─ @volar-plugins/css@1.0.0-beta.4
├─ @volar-plugins/emmet@1.0.0-beta.4
├─ @volar-plugins/json@1.0.0-beta.4
├─ @volar-plugins/pug-beautify@1.0.0-beta.4
├─ @volar-plugins/pug@1.0.0-beta.4
├─ @volar-plugins/typescript@1.0.0-beta.4
├─ @volar/language-server@1.0.0-beta.4
├─ @volar/pug-language-service@1.0.0-beta.4
├─ @volar/shared@1.0.0-beta.7
├─ @volar/typescript-faster@1.0.0-beta.4
├─ @volar/vue-language-server@1.0.0-beta.7
└─ @volar/vue-language-service@1.0.0-beta.7
✨  Done in 8.40s.
johnsoncodehk commented 1 year ago

Fortunately to know this! Could you try 1.0.0-beta.8?

yaegassy commented 1 year ago

I checked 1.0.0-beta.8. No problem. Thanks!

$ yarn upgrade @volar/vue-language-server@1.0.0-beta.8 @volar/shared@1.0.0-beta.8
yarn upgrade v1.22.19
[1/5] 🔍  Validating package.json...
warning @yaegassy/coc-volar@0.24.10: The engine "coc" appears to be invalid.
[2/5] 🔍  Resolving packages...
[3/5] 🚚  Fetching packages...
[4/5] 🔗  Linking dependencies...
warning " > coc.nvim@0.0.81" has incorrect peer dependency "@types/node@^12.12.0".
[5/5] 🔨  Rebuilding all packages...
success Saved lockfile.
success Saved 11 new dependencies.
info Direct dependencies
└─ @volar/vue-language-server@1.0.0-beta.8
info All dependencies
├─ @volar-plugins/css@1.0.0-beta.8
├─ @volar-plugins/emmet@1.0.0-beta.8
├─ @volar-plugins/json@1.0.0-beta.8
├─ @volar-plugins/pug-beautify@1.0.0-beta.8
├─ @volar-plugins/pug@1.0.0-beta.8
├─ @volar-plugins/typescript@1.0.0-beta.8
├─ @volar/language-server@1.0.0-beta.8
├─ @volar/pug-language-service@1.0.0-beta.8
├─ @volar/typescript-faster@1.0.0-beta.8
├─ @volar/vue-language-server@1.0.0-beta.8
└─ @volar/vue-language-service@1.0.0-beta.8
✨  Done in 10.35s.