]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix race condition when company-completing quickly
authorJoão Távora <joaotavora@gmail.com>
Mon, 21 Oct 2019 21:25:13 +0000 (22:25 +0100)
committerJoão Távora <joaotavora@gmail.com>
Mon, 21 Oct 2019 21:25:44 +0000 (22:25 +0100)
For some reason, probably related to the way that Eglot tries to
maintain the responsiveness of Company completion tooltips (see
below), the user's explicit input will sometimes be surprisingly
deleted by Company, leading to a horrible completion experience.

This is sometimes hard to reproduce, but appears to match this
description perfectly:
https://github.com/joaotavora/eglot/issues/319#issuecomment-542955432

Fortunately, Company has a good fix for this, which is to pass
`:company-require-match 'never` in the completion-at-point function.
This is the fix applied in this commit.

However, this line shouldn't be required since the default value for
`company-require-match` is `company-explicit-action-p`, presumably
meaning that the auto-deletion should never take place for characters
typed by the user.

This points to a bug in Company, or at least something which may have
been exacerbated by the way that Eglot aggressively fetches
completions from the server by passing :cancel-on-input to
`jsonrpc-request`, discarding out-of-date replies.  Perhaps that
discarding step bears with it some side-effects that make the
`company-explicit-action-p` test return `nil` instead of the correct
`t`.  Company interprets this as carte blanche to delete the last
inserted character.

* eglot.el (eglot-completion-at-point): Use :company-require-match
'never.

GitHub-reference: per https://github.com/joaotavora/eglot/issues/319

lisp/progmodes/eglot.el

index bd5f1ac8d4c985f05a2d356449bc6d8bc0cc2e50..92a35cab438d6f3d658c25a2e672188cc1adbbca 100644 (file)
@@ -2005,6 +2005,7 @@ is not active."
                (erase-buffer)
                (insert formatted)
                (current-buffer)))))
+       :company-require-match 'never
        :company-prefix-length
        (save-excursion
          (when (car bounds) (goto-char (car bounds)))