This repository has been archived by the owner on Dec 19, 2024. It is now read-only.
Ensure absolute file paths for diagnostics #77
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've been experiencing an issue with flow-for-vscode's diagnostics where I'm receiving errors like this when clicking on an error in the "problems" view:
I've dug into this a bit, and it seems the issue is related to a bad assumption that
flow status --json
always returns absolute paths. I'm guessing that most flow projects, the paths are absolute. This is the case with flow-for-vscode. However, with my project, the paths are relative to the project root – without a leading./
. This causes a problem when the file is converted into a URI withvscode.Uri.file
, which expects absolute paths and results in an invalid URI.This change ensures that the file path is always absolute, leveraging the
flowRoot
value fromflowFindDiagnostics
, before converting it into a URI withvscode.Uri.file
.For additional context, I'm pretty confident I know what is driving this inconsistency with the output of
flow status
. My project is configured to treat our top-levelsrc
directory to be treated as a module root usingmodule.system.node.resolve_dirname=src
. We do this so that we can import our own modules similarly to how we import modules fromnode_modules
. For example, importingcomponents/AddToDashboardSelect/AddToDashboardSelect
resolves to<PROJECT_ROOT>/src/components/AddToDashboardSelect/AddToDashboardSelect
.Sample output from
./node_modules/.bin/flow status --json
for my project:Compared to flow-for-vscode: