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

Turn off semantic highlighting on files with more than 100k chars #2481

Merged
merged 1 commit into from
Aug 23, 2024

Conversation

vinistock
Copy link
Member

Motivation

Closes #2461

This PR disables semantic highlighting for documents with over 100k characters. The TypeScript extension does the same thing for performance reasons.

For very large files, it gets to a point where the editor is simply unable to process the amount of tokens returned by the server at an acceptable speed and everything starts to lag. Ideally, we'd still want to highlight large files, but it's better to have the other features working than to make the editor unusable in these situations.

This PR brings our responses down to 200ms for a ~4k line file.

Implementation

The idea is to show a warning when a document with more characters than the limit is opened and then we return empty responses before doing any processing if that's the case.

Automated Tests

Added a test.

@vinistock vinistock added enhancement New feature or request server This pull request should be included in the server gem's release notes labels Aug 23, 2024
@vinistock vinistock self-assigned this Aug 23, 2024
@vinistock vinistock requested a review from a team as a code owner August 23, 2024 19:03
@vinistock vinistock requested review from andyw8 and st0012 August 23, 2024 19:03
@andyw8
Copy link
Contributor

andyw8 commented Aug 23, 2024

Does the TS extension give any warning to the user that highlighting is disabled due to the filesize?

Base automatically changed from vs-support-semantic-tokens-delta to main August 23, 2024 19:06
@vinistock vinistock force-pushed the vs-disable-semantic-highlighting-large-files branch from 8a9a1fd to 211edf8 Compare August 23, 2024 19:07
@vinistock
Copy link
Member Author

I'm not sure. But it does for other things. For example, I have already seen warnings related to folding ranges in very large JSON files. Do you think the warning is not necessary?

@andyw8
Copy link
Contributor

andyw8 commented Aug 23, 2024

Was just curious about the wording they used.

@vinistock vinistock merged commit 20ff3b1 into main Aug 23, 2024
36 checks passed
@vinistock vinistock deleted the vs-disable-semantic-highlighting-large-files branch August 23, 2024 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request server This pull request should be included in the server gem's release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for semantic tokens delta
2 participants