@@ -243,26 +243,21 @@ version."
243
243
(lsp-lens--display (apply #'append (-map #'cl-rest backend-data)))))
244
244
version)
245
245
246
- (lsp-defun lsp--lens-backend-not-loaded? (range
247
- (&CodeLens :range
246
+ (lsp-defun lsp--lens-backend-not-loaded? ((&CodeLens :range
248
247
(&Range :start )
249
248
:command?
250
249
:_pending pending))
251
250
" 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))))
255
256
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? ))
257
258
" 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 )))))
266
261
267
262
(defun lsp-lens--backend-fetch-missing (lenses callback file-version )
268
263
" Fetch LENSES without command in for the current window.
@@ -281,14 +276,10 @@ FILE-VERSION - the version of the file."
281
276
(-lambda ((&CodeLens :command? ))
282
277
(lsp-put it :_pending nil )
283
278
(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)
287
280
(funcall callback lenses file-version)))
288
281
: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)))
292
283
293
284
(defun lsp-lens--backend (modified? callback )
294
285
" Lenses backend using `textDocument/codeLens' .
@@ -315,9 +306,7 @@ CALLBACK - callback for the lenses."
315
306
:mode 'tick
316
307
:no-merge t
317
308
: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)
321
310
(funcall callback lsp-lens--backend-cache lsp--cur-version)
322
311
(lsp-lens--backend-fetch-missing lsp-lens--backend-cache callback lsp--cur-version)))))
323
312
0 commit comments