-
Notifications
You must be signed in to change notification settings - Fork 706
feat(ls): fix go to definition #1710
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
base: main
Are you sure you want to change the base?
Conversation
return fh.Content(), true | ||
} | ||
return "", false | ||
return fs.source.FS().ReadFile(path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes issues with being able to get the source map files. It conforms to the fallback mechanism that TypeScript had which was going to the disk - https://github.com/microsoft/TypeScript/blob/release-5.9/src/services/sourcemaps.ts#L147-L151
"gotest.tools/v3/assert" | ||
) | ||
|
||
func TestInternalAliasGoToDefinition(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I specifically added this to have an automated test for functionality that wasn't tested by the baselines.
Overview
These changes made it so I could go to a proper definition. This approach aligns with the way the TypeScript version of the compiler does it using VFS only and VLQ decoding.
Basically we have a situation where we have an import in a
.ts
file likein a directory like
apps/app-one
in anindex.ts
file and the@latticehr
is an alias that should referencepackages/o11y
and it does go to thepackages/o11y/dist/*.d.ts
file although not the source file implementationThis gets to the correct file and line position using VLQ decoding like the TS version does.
This is an alternative approach to #1627 in a simpler way reusing existing functionality.