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

Remove read file contents request sent to extension by language server (use is file check) #3198

Merged
merged 3 commits into from
Feb 2, 2023

Conversation

mattseddon
Copy link
Member

@mattseddon mattseddon commented Feb 1, 2023

This PR removes the need for the language server to request that the extension reads the contents of files. We may need to bring this back in the future but for now we don't need it.

Comments inline.

Closes #2529 (cc @shcheklein)

}
export const getLocationToOpen = (uri: string): Location => {
const position = Position.create(0, 0)
const range = Range.create(position, position)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[F] Turns out that we can open the file using an empty range (previously this didn't work or I had done the wrong thing to test). This means we don't need the file contents at all (for now). We can simply check whether or not the URI relates to a file. If it does then we can create a location with the URI string and an empty range. Passing this back to the client will open the file. If there are multiple locations (files) then the user will be prompted which one they want to open. That's the reason that we can't just ask the extension to open the file without first returning information to the server.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also have to check whether or not the file is a file on the extension side because the LSP might not be running in a context that can access the file system (e.g Codespaces)

@mattseddon mattseddon force-pushed the remove-read-file-contents branch from 0cc2af3 to 8c6db6f Compare February 1, 2023 23:02
@mattseddon mattseddon marked this pull request as ready for review February 1, 2023 23:07
@mattseddon mattseddon enabled auto-merge (squash) February 2, 2023 18:41
@codeclimate
Copy link

codeclimate bot commented Feb 2, 2023

Code Climate has analyzed commit 801067b and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 80.9% (85% is the threshold).

This pull request will bring the total coverage in the repository to 95.9% (0.0% change).

View more on Code Climate.

@mattseddon mattseddon merged commit 0d88c95 into main Feb 2, 2023
@mattseddon mattseddon deleted the remove-read-file-contents branch February 2, 2023 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test and release LSP
2 participants