From 2dd1f6a2dc8ae1d507385fcb9edd95602fd7dcb9 Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Wed, 13 Jan 2016 10:54:00 +0300 Subject: [PATCH 1/1] company-cancel: Call frontends' 'hide before 'post-completion Fixes #449 --- company.el | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/company.el b/company.el index 78aa92b45..1b3a4429e 100644 --- a/company.el +++ b/company.el @@ -1524,13 +1524,20 @@ from the rest of the backends in the group, if any, will be left at the end." (defun company-cancel (&optional result) (unwind-protect - (when company-prefix - (if (stringp result) - (progn - (company-call-backend 'pre-completion result) - (run-hook-with-args 'company-completion-finished-hook result) - (company-call-backend 'post-completion result)) - (run-hook-with-args 'company-completion-cancelled-hook result))) + (progn + (when company-timer + (cancel-timer company-timer)) + (company-echo-cancel t) + (company-search-mode 0) + (company-call-frontends 'hide) + (company-enable-overriding-keymap nil) + (when company-prefix + (if (stringp result) + (progn + (company-call-backend 'pre-completion result) + (run-hook-with-args 'company-completion-finished-hook result) + (company-call-backend 'post-completion result)) + (run-hook-with-args 'company-completion-cancelled-hook result)))) (setq company-backend nil company-prefix nil company-candidates nil @@ -1543,13 +1550,7 @@ from the rest of the backends in the group, if any, will be left at the end." company--manual-action nil company--manual-prefix nil company--point-max nil - company-point nil) - (when company-timer - (cancel-timer company-timer)) - (company-echo-cancel t) - (company-search-mode 0) - (company-call-frontends 'hide) - (company-enable-overriding-keymap nil)) + company-point nil)) ;; Make return value explicit. nil) @@ -2958,8 +2959,8 @@ Returns a negative number if the tooltip should be displayed above point." "}"))) (defun company-echo-hide () - (unless (equal company-echo-last-msg "") - (setq company-echo-last-msg "") + (unless (null company-echo-last-msg) + (setq company-echo-last-msg nil) (company-echo-show))) (defun company-echo-frontend (command) -- 2.39.2