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

Casing issue in uri.path between formatted diagnostics and hoverProvider #100

Closed
kevinramharak opened this issue Mar 20, 2024 · 2 comments
Closed
Labels
bug Something isn't working

Comments

@kevinramharak
Copy link
Contributor

kevinramharak commented Mar 20, 2024

Describe the bug
I noticed that I did not get any prettified errors when working from a .vue file.

I setup a basic snippet like:

<script setup lang="ts">
import { RouterView } from 'vue-router';

const x = [1, 2, 3, '4'];

function y(param: number[]) {

}

y(x); 

</script>
<template>
    <RouterView />
</template>

And per screenshot the highlighter result:
image

Expected behavior
I expected to see a prettified error message as vue support is implemented.

Cause
I cloned the repo and ran it with the debugger and found that this issue is caused by the following:

uriStore[uri.path] = items;

On this line the value of uri.path is: '/c:/Users/kevin/Documents/Projects/phavuer-playground/src/App.vue'

When in the hoverProvider.ts:

const itemsInUriStore = uriStore[document.uri.path];
if (!itemsInUriStore) {
return null;
}

The value of document.uri.path is '/C:/Users/kevin/Documents/Projects/phavuer-playground/src/App.vue'.

Notice the casing difference of the C drive:

- '/c:/Users/kevin/Documents/Projects/phavuer-playground/src/App.vue'
+ '/C:/Users/kevin/Documents/Projects/phavuer-playground/src/App.vue'

This causes the hoverProvider to think there are no stored items to show, and thus show no results.

Fix
VS Code seems to use this implementation for the Uri class.

Maybe use fsPath instead as it states:

/**
* Returns a string representing the corresponding file system path of this URI.
* Will handle UNC paths, normalizes windows drive letters to lower-case, and uses the
* platform specific path separator.
*
* * Will *not* validate the path for invalid characters and semantics.
* * Will *not* look at the scheme of this URI.
* * The result shall *not* be used for display purposes but for accessing a file on disk.
*
*
* The *difference* to `URI#path` is the use of the platform specific separator and the handling
* of UNC paths. See the below sample of a file-uri with an authority (UNC path).
*/
@kevinramharak kevinramharak added the bug Something isn't working label Mar 20, 2024
yoavbls added a commit that referenced this issue Apr 7, 2024
* Try to fix Casing issue in uri.path between formatted diagnostics and hoverProvider #100

* Add ts-plugin diagnostic source for Vue Hybrid mode

* Bump version
@yoavbls
Copy link
Owner

yoavbls commented Apr 8, 2024

Thank you for the detailed issue!
I think the main reason it didn't work is that In the new official extension of Vue VSCode plugin, Hybrid mode is enabled by default, which means that a TypeScript LSP Plugin publishes the diagnostics as ts-plugin instead of ts.
I fixed it in #103, published in v0.5.4.
I also moved to fsPath. It is better, and I wasn't aware of that. Thank you!

@yoavbls yoavbls closed this as completed Apr 8, 2024
@sentience
Copy link

@yoavbls Looks like v0.5.4 still needs to be merged into main (or perhaps you just haven't pushed your changes to main)?

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

3 participants