Skip to content

Commit

Permalink
Revert "Filter lenses that are not visible without converting to Posi…
Browse files Browse the repository at this point in the history
…tion" (#4073)

This reverts commit 18c94fa.
  • Loading branch information
iitalics authored Jun 14, 2023
1 parent 9ee4a2b commit 448a2fd
Showing 1 changed file with 12 additions and 23 deletions.
35 changes: 12 additions & 23 deletions lsp-lens.el
Original file line number Diff line number Diff line change
Expand Up @@ -243,26 +243,21 @@ version."
(lsp-lens--display (apply #'append (-map #'cl-rest backend-data)))))
version)

(lsp-defun lsp--lens-backend-not-loaded? (range
(&CodeLens :range
(lsp-defun lsp--lens-backend-not-loaded? ((&CodeLens :range
(&Range :start)
:command?
:_pending pending))
"Return t if LENS has to be loaded."
(and (not command?)
(not pending)
(lsp-point-in-range? start range)))
(let ((window (get-buffer-window (current-buffer))))
;; (window-start/end) does not consider current window buffer if not passed manually
(and (< (window-start window) (lsp--position-to-point start) (window-end window))
(not command?)
(not pending))))

(lsp-defun lsp--lens-backend-present? (range (&CodeLens :range (&Range :start) :command?))
(lsp-defun lsp--lens-backend-present? ((&CodeLens :range (&Range :start) :command?))
"Return t if LENS has to be loaded."
(or command? (not (lsp-point-in-range? start range))))

(defun lsp-lens--window-range ()
"Return the window Range"
(let ((window (get-buffer-window (current-buffer))))
(lsp-make-range
:start (lsp--point-to-position (window-start window))
:end (lsp--point-to-position (window-end window)))))
(or command?
(not (< (window-start) (lsp--position-to-point start) (window-end)))))

(defun lsp-lens--backend-fetch-missing (lenses callback file-version)
"Fetch LENSES without command in for the current window.
Expand All @@ -281,14 +276,10 @@ FILE-VERSION - the version of the file."
(-lambda ((&CodeLens :command?))
(lsp-put it :_pending nil)
(lsp-put it :command command?)
(when (seq-every-p (-partial #'lsp--lens-backend-present?
(lsp-lens--window-range))
lenses)
(when (seq-every-p #'lsp--lens-backend-present? lenses)
(funcall callback lenses file-version)))
:mode 'tick)))
(seq-filter (-partial #'lsp--lens-backend-not-loaded?
(lsp-lens--window-range))
lenses)))
(seq-filter #'lsp--lens-backend-not-loaded? lenses)))

(defun lsp-lens--backend (modified? callback)
"Lenses backend using `textDocument/codeLens'.
Expand All @@ -315,9 +306,7 @@ CALLBACK - callback for the lenses."
:mode 'tick
:no-merge t
:cancel-token (concat (buffer-name (current-buffer)) "-lenses")))
(if (-all? (-partial #'lsp--lens-backend-present?
(lsp-lens--window-range))
lsp-lens--backend-cache)
(if (-all? #'lsp--lens-backend-present? lsp-lens--backend-cache)
(funcall callback lsp-lens--backend-cache lsp--cur-version)
(lsp-lens--backend-fetch-missing lsp-lens--backend-cache callback lsp--cur-version)))))

Expand Down

0 comments on commit 448a2fd

Please sign in to comment.