Skip to content

Commit

Permalink
fix: ensure the callback is still executing in the context of the ori…
Browse files Browse the repository at this point in the history
…ginal buffer
  • Loading branch information
kassick committed Nov 27, 2024
1 parent 80e210a commit 3c43167
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lsp-inline-completion.el
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,10 @@ lsp-inline-completion-mode is active"
(defvar-local lsp-inline-completion--idle-timer nil
"The idle timer used by lsp-inline-completion-mode")

(defun lsp-inline-completion--maybe-display ()
(unless (--any (funcall it) lsp-inline-completion-inhibit-predicates)
(defun lsp-inline-completion--maybe-display (buffer)
(when (and (buffer-live-p buffer)
(eq (current-buffer) buffer)
(--none? (funcall it) lsp-inline-completion-inhibit-predicates))
(setq last-command this-command)
(setq this-command 'lsp-inline-completion-display)
(lsp-inline-completion-display 'implicit)))
Expand All @@ -404,10 +406,12 @@ lsp-inline-completion-mode is active"
(when (and lsp-inline-completion-mode lsp--buffer-workspaces)
(when lsp-inline-completion--idle-timer
(cancel-timer lsp-inline-completion--idle-timer))
(setq lsp-inline-completion--idle-timer
(run-with-timer lsp-inline-completion-idle-delay
nil
#'lsp-inline-completion--maybe-display))))
(let ((buffer (current-buffer)))
(setq lsp-inline-completion--idle-timer
(run-with-timer lsp-inline-completion-idle-delay
nil
#'lsp-inline-completion--maybe-display
buffer)))))

(define-minor-mode lsp-inline-completion-mode
"Mode automatically displaying inline completions."
Expand Down

0 comments on commit 3c43167

Please sign in to comment.