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

Optimize overlay creation by checking window visibility first #4511

Conversation

eval-exec
Copy link
Contributor

  • I added a new entry to CHANGELOG.md

  • I updated documentation if applicable (docs folder)

This PR refactors the lsp--document-highlight-callback function to enhance its performance. By rearranging the conditions, we now check window visibility before calculating the start and end points of overlays. This change prevents the creation of overlay points and subsequent overlays for highlights that are not visible in any window, thus reducing unnecessary computations and improving efficiency. The logic for skipping the current symbol highlighting remains intact.

@eval-exec eval-exec force-pushed the exec/improve-lsp--document-highlight-callback branch from 8a13535 to f57fd3e Compare July 28, 2024 08:30
@eval-exec eval-exec marked this pull request as ready for review July 28, 2024 08:31
@@ -6260,15 +6260,15 @@ A reference is highlighted only if it is visible in a window."
(-map
(-lambda ((start-window . end-window))
;; Make the overlay only if the reference is visible
(let ((start-point (lsp--position-to-point start))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think (lsp--position-to-point start) and (lsp--position-to-point end) is a heavy job.

@eval-exec
Copy link
Contributor Author

I think this PR is ready to merge. 💙

@jcs090218 jcs090218 merged commit f02aac0 into emacs-lsp:master Sep 23, 2024
11 of 13 checks passed
@jcs090218
Copy link
Member

Thank you!

@eval-exec eval-exec deleted the exec/improve-lsp--document-highlight-callback branch September 23, 2024 05:38
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.

3 participants