From f02aac0caf9b42a2e91c4df53a655a291783948c Mon Sep 17 00:00:00 2001 From: Eval Exec Date: Mon, 23 Sep 2024 13:38:20 +0800 Subject: [PATCH] Refactor lsp--document-highlight-callback to check window visibility before constructing overlay (#4511) --- CHANGELOG.org | 2 ++ lsp-mode.el | 18 +++++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.org b/CHANGELOG.org index eaabc1d1b1..b847e60a56 100644 --- a/CHANGELOG.org +++ b/CHANGELOG.org @@ -12,6 +12,8 @@ * 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. * 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"]~. * Add futhark support + * Optimize overlay creation by checking window visibility first + ** 9.0.0 * Add language server config for QML (Qt Modeling Language) using qmlls. diff --git a/lsp-mode.el b/lsp-mode.el index 59de08a2d6..19600a78a3 100644 --- a/lsp-mode.el +++ b/lsp-mode.el @@ -6262,15 +6262,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)) - (end-point (lsp--position-to-point end))) - (when (and (> (1+ start-line) start-window) - (< (1+ end-line) end-window) - (not (and lsp-symbol-highlighting-skip-current - (<= start-point (point) end-point)))) - (-doto (make-overlay start-point end-point) - (overlay-put 'face (cdr (assq (or kind? 1) lsp--highlight-kind-face))) - (overlay-put 'lsp-highlight t))))) + (when (and (> (1+ start-line) start-window) + (< (1+ end-line) end-window)) + (let ((start-point (lsp--position-to-point start)) + (end-point (lsp--position-to-point end))) + (when (not (and lsp-symbol-highlighting-skip-current + (<= start-point (point) end-point))) + (-doto (make-overlay start-point end-point) + (overlay-put 'face (cdr (assq (or kind? 1) lsp--highlight-kind-face))) + (overlay-put 'lsp-highlight t)))))) wins-visible-pos)) highlights)))