Skip to content

Commit 448a2fd

Browse files
authored
Revert "Filter lenses that are not visible without converting to Position" (#4073)
This reverts commit 18c94fa.
1 parent 9ee4a2b commit 448a2fd

File tree

1 file changed

+12
-23
lines changed

1 file changed

+12
-23
lines changed

lsp-lens.el

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -243,26 +243,21 @@ version."
243243
(lsp-lens--display (apply #'append (-map #'cl-rest backend-data)))))
244244
version)
245245

246-
(lsp-defun lsp--lens-backend-not-loaded? (range
247-
(&CodeLens :range
246+
(lsp-defun lsp--lens-backend-not-loaded? ((&CodeLens :range
248247
(&Range :start)
249248
:command?
250249
:_pending pending))
251250
"Return t if LENS has to be loaded."
252-
(and (not command?)
253-
(not pending)
254-
(lsp-point-in-range? start range)))
251+
(let ((window (get-buffer-window (current-buffer))))
252+
;; (window-start/end) does not consider current window buffer if not passed manually
253+
(and (< (window-start window) (lsp--position-to-point start) (window-end window))
254+
(not command?)
255+
(not pending))))
255256

256-
(lsp-defun lsp--lens-backend-present? (range (&CodeLens :range (&Range :start) :command?))
257+
(lsp-defun lsp--lens-backend-present? ((&CodeLens :range (&Range :start) :command?))
257258
"Return t if LENS has to be loaded."
258-
(or command? (not (lsp-point-in-range? start range))))
259-
260-
(defun lsp-lens--window-range ()
261-
"Return the window Range"
262-
(let ((window (get-buffer-window (current-buffer))))
263-
(lsp-make-range
264-
:start (lsp--point-to-position (window-start window))
265-
:end (lsp--point-to-position (window-end window)))))
259+
(or command?
260+
(not (< (window-start) (lsp--position-to-point start) (window-end)))))
266261

267262
(defun lsp-lens--backend-fetch-missing (lenses callback file-version)
268263
"Fetch LENSES without command in for the current window.
@@ -281,14 +276,10 @@ FILE-VERSION - the version of the file."
281276
(-lambda ((&CodeLens :command?))
282277
(lsp-put it :_pending nil)
283278
(lsp-put it :command command?)
284-
(when (seq-every-p (-partial #'lsp--lens-backend-present?
285-
(lsp-lens--window-range))
286-
lenses)
279+
(when (seq-every-p #'lsp--lens-backend-present? lenses)
287280
(funcall callback lenses file-version)))
288281
:mode 'tick)))
289-
(seq-filter (-partial #'lsp--lens-backend-not-loaded?
290-
(lsp-lens--window-range))
291-
lenses)))
282+
(seq-filter #'lsp--lens-backend-not-loaded? lenses)))
292283

293284
(defun lsp-lens--backend (modified? callback)
294285
"Lenses backend using `textDocument/codeLens'.
@@ -315,9 +306,7 @@ CALLBACK - callback for the lenses."
315306
:mode 'tick
316307
:no-merge t
317308
:cancel-token (concat (buffer-name (current-buffer)) "-lenses")))
318-
(if (-all? (-partial #'lsp--lens-backend-present?
319-
(lsp-lens--window-range))
320-
lsp-lens--backend-cache)
309+
(if (-all? #'lsp--lens-backend-present? lsp-lens--backend-cache)
321310
(funcall callback lsp-lens--backend-cache lsp--cur-version)
322311
(lsp-lens--backend-fetch-missing lsp-lens--backend-cache callback lsp--cur-version)))))
323312

0 commit comments

Comments
 (0)