Skip to content

Commit f02aac0

Browse files
authored
Refactor lsp--document-highlight-callback to check window visibility before constructing overlay (#4511)
1 parent 4abe804 commit f02aac0

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

CHANGELOG.org

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
* Fix bug in ~rust-analyzer.check.features~ configuration via ~lsp-rust-checkonsave-features~ Emacs setting: we were defaulting to ~[]~, but ~rust-analyzer~ defaults to inheriting the value from ~rust-analyzer.cargo.features~. The bug resulted in code hidden behind features not getting type checked when those features were enabled by setting ~rust-analyzer.cargo.features~ via the ~lsp-rust-features~ Emacs setting.
1313
* Change ~ruff-lsp~ to ~ruff~ for python lsp client. All ~ruff-lsp~ customizable variable change to ~ruff~. Lsp server command now is ~["ruff" "server"]~ instead of ~["ruff-lsp"]~.
1414
* Add futhark support
15+
* Optimize overlay creation by checking window visibility first
16+
1517

1618
** 9.0.0
1719
* Add language server config for QML (Qt Modeling Language) using qmlls.

lsp-mode.el

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6262,15 +6262,15 @@ A reference is highlighted only if it is visible in a window."
62626262
(-map
62636263
(-lambda ((start-window . end-window))
62646264
;; Make the overlay only if the reference is visible
6265-
(let ((start-point (lsp--position-to-point start))
6266-
(end-point (lsp--position-to-point end)))
6267-
(when (and (> (1+ start-line) start-window)
6268-
(< (1+ end-line) end-window)
6269-
(not (and lsp-symbol-highlighting-skip-current
6270-
(<= start-point (point) end-point))))
6271-
(-doto (make-overlay start-point end-point)
6272-
(overlay-put 'face (cdr (assq (or kind? 1) lsp--highlight-kind-face)))
6273-
(overlay-put 'lsp-highlight t)))))
6265+
(when (and (> (1+ start-line) start-window)
6266+
(< (1+ end-line) end-window))
6267+
(let ((start-point (lsp--position-to-point start))
6268+
(end-point (lsp--position-to-point end)))
6269+
(when (not (and lsp-symbol-highlighting-skip-current
6270+
(<= start-point (point) end-point)))
6271+
(-doto (make-overlay start-point end-point)
6272+
(overlay-put 'face (cdr (assq (or kind? 1) lsp--highlight-kind-face)))
6273+
(overlay-put 'lsp-highlight t))))))
62746274
wins-visible-pos))
62756275
highlights)))
62766276

0 commit comments

Comments
 (0)