@@ -407,6 +407,21 @@ lsp-inline-completion-mode is active."
407
407
(defvar-local lsp-inline-completion--idle-timer nil
408
408
" The idle timer used by lsp-inline-completion-mode." )
409
409
410
+ (defvar-local lsp-inline-completion--inhibit-idle-timer nil
411
+ " Flag to indicate we do not want the timer to show inline completions. Reset on change." )
412
+
413
+ ;;;### autoload
414
+ (defun lsp-inline-completion-inhibit-idle-completions ()
415
+ (setq lsp-inline-completion--inhibit-idle-timer t ))
416
+
417
+ ;;;### autoload
418
+ (defun lsp-inline-completion-uninhibit-idle-completions ()
419
+ (setq lsp-inline-completion--inhibit-idle-timer nil ))
420
+
421
+ ;;;### autoload
422
+ (defun lsp-inline-completion-is-inhibited ()
423
+ lsp-inline-completion--inhibit-idle-timer)
424
+
410
425
;;;### autoload
411
426
(defun lsp-inline-completion-cancel-timer ()
412
427
" Cancels the completion idle timer, if set"
@@ -420,19 +435,31 @@ lsp-inline-completion-mode is active."
420
435
:lighter nil
421
436
(cond
422
437
((and lsp-inline-completion-mode lsp--buffer-workspaces)
438
+ (add-hook 'after-change-functions #'lsp-inline-completion--uninhibit-on-change nil t )
423
439
(add-hook 'lsp-on-change-hook #'lsp-inline-completion--after-change nil t ))
424
440
425
441
(t
426
442
(lsp-inline-completion-cancel-timer)
427
443
428
444
(lsp-inline-completion-cancel)
429
445
446
+ (remove-hook 'after-change-functions #'lsp-inline-completion--uninhibit-on-change t )
430
447
(remove-hook 'lsp-on-change-hook #'lsp-inline-completion--after-change t ))))
431
448
449
+ (defun lsp-inline-completion--uninhibit-on-change (&rest _ )
450
+ " Resets the uninhibit flag. "
451
+
452
+ ; ; Must be done in after-change-functions instead of lsp-on-change-hook,
453
+ ; ; because LSP's hook happens after lsp-idle-delay. If the user calls some
454
+ ; ; function that sets the inhibit flag to t *before* the idle delay, we may
455
+ ; ; end up overriding the flag."
456
+ (lsp-inline-completion-uninhibit-idle-completions))
457
+
432
458
(defun lsp-inline-completion--maybe-display (original-buffer original-point )
433
459
; ; This is executed on an idle timer -- ensure state did not change before
434
460
; ; displaying
435
- (when (and (buffer-live-p original-buffer)
461
+ (when (and (not (lsp-inline-completion-is-inhibited))
462
+ (buffer-live-p original-buffer)
436
463
(eq (current-buffer ) original-buffer)
437
464
(eq (point ) original-point)
438
465
(--none? (funcall it) lsp-inline-completion-inhibit-predicates))
@@ -463,6 +490,7 @@ lsp-inline-completion-mode is active."
463
490
(when (and lsp-inline-completion-enable
464
491
(lsp-feature? " textDocument/inlineCompletion" ))
465
492
(lsp-inline-completion-mode))))
493
+
466
494
467
495
; ; Company default integration
468
496
0 commit comments