From 36f294c2d5fb975f888539f9aef88100bf2db0ab Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jo=C3=A3o=20T=C3=A1vora?= Date: Tue, 5 Feb 2019 21:49:38 +0000 Subject: [PATCH] Don't teardown company if started via trigger chars Reported by zhanghj in https://github.com/company-mode/company-mode/issues/866 * eglot.el (eglot-completion-at-point): More carefully calculate :company-prefix-length --- lisp/progmodes/eglot.el | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 2d1c3676f22..a4b7f8f8e63 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -1911,9 +1911,12 @@ is not active." (insert formatted) (current-buffer))))) :company-prefix-length - (cl-some #'looking-back - (mapcar #'regexp-quote - (plist-get completion-capability :triggerCharacters))) + (save-excursion + (when (car bounds) (goto-char (car bounds))) + (looking-back + (regexp-opt + (cl-coerce (cl-getf completion-capability :triggerCharacters) 'list)) + (line-beginning-position))) :exit-function (lambda (comp _status) (let ((comp (if (get-text-property 0 'eglot--lsp-completion comp) -- 2.39.2