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

VSCode: Semantic token range off by 1 in store accesses #762

Closed
Monkatraz opened this issue Jan 14, 2021 · 4 comments
Closed

VSCode: Semantic token range off by 1 in store accesses #762

Monkatraz opened this issue Jan 14, 2021 · 4 comments
Labels
bug Something isn't working Fixed Fixed in master branch. Pending production release.

Comments

@Monkatraz
Copy link
Contributor

Monkatraz commented Jan 14, 2021

image

Looks like the $ was not accounted for in the range offset.

@Monkatraz Monkatraz added the bug Something isn't working label Jan 14, 2021
@jasonlyu123
Copy link
Member

$ Is because it's transformed into a function in svelte2tsx and r is a source mapping issue like the one in each block.

@Monkatraz
Copy link
Contributor Author

Ah, that makes sense. Man, that source-mapping issue is a real thorn in the side. Feel free to close if you feel that this is a duplicate.

@dummdidumm
Copy link
Member

I think there's no previous issue like this so I prefer to keep it open for visibility and to track it.

dummdidumm pushed a commit to dummdidumm/language-tools that referenced this issue Jan 26, 2021
If a range is in the same line, and the mapped range has one character more than the original range, add +1 to the end character of the original range.
Assumption is that we never alter the length of a mapped token.

This "one character short" mapping happens because a range's end is exclusive, so the character at the range's end is not part of the range. That means the end character can be on a character which was added as part of the transformation and is not present in the original output. The mapper rightfully maps this to the first mapped character before it - which means that the range then is one character short.

sveltejs#762
dummdidumm added a commit that referenced this issue Jan 26, 2021
If a range is in the same line, and the mapped range has one character more than the original range, add +1 to the end character of the original range.
Assumption is that we never alter the length of a mapped token.

This "one character short" mapping happens because a range's end is exclusive, so the character at the range's end is not part of the range. That means the end character can be on a character which was added as part of the transformation and is not present in the original output. The mapper rightfully maps this to the first mapped character before it - which means that the range then is one character short.

#762
@dummdidumm dummdidumm added the Fixed Fixed in master branch. Pending production release. label Jan 26, 2021
@jasonlyu123 jasonlyu123 removed the Fixed Fixed in master branch. Pending production release. label Jan 28, 2021
@jasonlyu123
Copy link
Member

The semantic tokens feature doesn't use the mapRangeToOriginal function to source map so it's not fixed. reopen this

@jasonlyu123 jasonlyu123 reopened this Jan 28, 2021
@jasonlyu123 jasonlyu123 added the Fixed Fixed in master branch. Pending production release. label Jan 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Fixed Fixed in master branch. Pending production release.
Projects
None yet
Development

No branches or pull requests

3 participants