Skip to content

Add warning when open file outside workspace #1119

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

Merged
merged 3 commits into from
Apr 7, 2019

Conversation

edwin0cheng
Copy link
Member

@edwin0cheng edwin0cheng commented Apr 6, 2019

When file is not found in ra_vfs but exist, use LspError for warning instead of error_fmt to bail out error,

Temporarily fix #967 .

edit: typo

@matklad
Copy link
Member

matklad commented Apr 7, 2019

Excellent idea!

We probably shouldn't be checking specifically if the path exists: VSCode can send us in-memory files. In general, we should interract with fs only via vfs.

@edwin0cheng
Copy link
Member Author

Fixed 👍

@edwin0cheng
Copy link
Member Author

We probably shouldn't be checking specifically if the path exists: VSCode can send us in-memory files. In general, we should interract with fs only via vfs.

If we only handle files via vfs, what is the proper way to handle this error ? Currently even we pass this error back to vscode, when the user do other actions, it will send the warnings again and again, and is still very annoying. Should we add some kind of cached mechanism which suppress the warning (cancel the action) when it happens before ?

On the other hand, could it possible to add a new api which allow us to add a new Roots in ra_vfs after initialization ? If so, we can check whether file exists and the file's ancestor directory is a cargo workspace And then we add that directory in the new roots.

@matklad
Copy link
Member

matklad commented Apr 7, 2019

bors r+

Ideally, this should not be an error at all: we should just add the file to some kind of "default" VFS root. According to the protocol, it is valid for the client to send arbitrary files to the server.

However in practice, if we get a lot of such warnings, that probably means that something is misconfigurated on our side (as opposed to client genuinelly sending us random files)

bors bot added a commit that referenced this pull request Apr 7, 2019
1119: Add warning when open file outside workspace r=matklad a=edwin0cheng

When file is not found in `ra_vfs` but exist, use `LspError` for warning instead of `error_fmt` to bail out error, 

Temporarily fix #967 .

edit: typo

Co-authored-by: Edwin Cheng <[email protected]>
@bors
Copy link
Contributor

bors bot commented Apr 7, 2019

Build succeeded

@bors bors bot merged commit ce3d783 into rust-lang:master Apr 7, 2019
@edwin0cheng edwin0cheng deleted the fix_967 branch April 8, 2019 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Open a file outside the project throw error
2 participants