-
Notifications
You must be signed in to change notification settings - Fork 689
[LSP] fix go to definition #1627
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
@microsoft-github-policy-service agree |
Keeping an eye on this... |
internal/project/compilerhost.go
Outdated
// Fallback to underlying FS for files not tracked by the program (like .d.ts.map) | ||
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 shouldn't be added onto the compilerhost since d.ts.map
is only used by ls features. Can you refactor so only the calls to readFile
in definitionSourceMap
has this fallback for d.ts.map
files? It should probably also read into the snapshot's fs
, instead of the underlying file system
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.
Makes sense, I'll adjust that
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.
@iisaduan I made the change with an alternative method here. Turns out that fs.source.FS()
is the snapshot FS
This is working for multiple engineers internally for us 😄 |
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 also enables the differentiation between "Go to Definition" and "Go to Type Definition". They both work now.
I'd love to get some feedback and modify this to fit standards that you all have.