branch: master
commit a78f7d8fe04fa41adf88e64a85f3beb013f8c48c
Merge: 07c56b1 5118b59
Author: Dmitry Gutov <[email protected]>
Commit: GitHub <[email protected]>
Merge pull request #764 from nikital/tng-supress-post-completion
company-tng: Suppress post-completion
---
company-tng.el | 13 ++++++++++++-
company.el | 1 -
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/company-tng.el b/company-tng.el
index 46592da..a1d7173 100644
--- a/company-tng.el
+++ b/company-tng.el
@@ -102,7 +102,8 @@ confirm the selection and finish the completion."
(when (and company-selection-changed
(not (company--company-command-p (this-command-keys))))
(company--unread-this-command-keys)
- (setq this-command 'company-complete-selection)))))
+ (setq this-command 'company-complete-selection)
+ (advice-add 'company-call-backend :before-until
'company-tng--supress-post-completion)))))
;;;###autoload
(defun company-tng-configure-default ()
@@ -159,5 +160,15 @@ made explicitly (i.e. `company-selection-changed' is true)"
(setf (nth 3 args) nil))
args)
+(defun company-tng--supress-post-completion (command &rest args)
+ "Installed as a :before-until advice on `company-call-backend' and
+prevents the 'post-completion command from being delivered to the backend
+for the next iteration. post-completion do things like expand snippets
+which are undesirable because completions are implicit in company-tng and
+visible side-effects after the completion are surprising."
+ (when (eq command 'post-completion)
+ (advice-remove 'company-call-backend 'company-tng--supress-post-completion)
+ t))
+
(provide 'company-tng)
;;; company-tng.el ends here
diff --git a/company.el b/company.el
index 4c79f59..cbe3781 100644
--- a/company.el
+++ b/company.el
@@ -1629,7 +1629,6 @@ prefix match (same case) will be prioritized."
;; `company-completion-finished-hook' in that case, with right argument.
(if (stringp result)
(let ((company-backend backend))
- (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))))