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

Improve strategy for semantic highlighting requests #2020

Merged
merged 1 commit into from
Aug 18, 2022

Conversation

jwortmann
Copy link
Member

This is a small optimization for semantic highlighting:

  • If a very big file was just opened, initially request tokens only for
    the visible range (if the server supports it), and after the response
    arrives also request tokens for the rest of the file. This way
    semantic highlighting can be shown faster for the currently visible
    part of the file, and for the rest of the file it will be applied a
    little bit later.

  • If the server supports only the semanticTokens/range request, use the
    entire file range for the requested content range while typing. By
    doing this, semantic highlighting is also visible after scrolling the
    file and it prevents unpleasant highlighting updates when typing after
    scrolling to another position.

With LSP-lua and a 165kb file:

Before:

Click to show GIF

full

Time between request send and response arrives (counted from screen record with 60Hz): 166 frames = 2.77 sec

After:

Click to show GIF

range

Time between request send and response arrives: 13 frames = 0.22 sec

* If a very big file was just opened, initially request tokens only for
  the visible range (if the server supports it), and after the response
  arrives also request tokens for the rest of the file. This way
  semantic highlighting can be shown faster for the currently visible
  part of the file, and for the rest of the file it will be applied a
  little bit later.

* If the server supports only the semanticTokens/range request, use the
  entire file range for the requested content range while typing. By
  doing this, semantic highlighting is also visible after scrolling the
  file and it prevents unpleasant highlighting updates when typing after
  scrolling to another position.
@rwols rwols merged commit 82cf4a2 into sublimelsp:main Aug 18, 2022
@jwortmann jwortmann deleted the semantic-tokens-range branch August 18, 2022 05:44
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.

3 participants