branch: master
commit 5118b59668b1e65c8631c1bebac36b9c4320598a
Author: Nikita Leshenko <[email protected]>
Commit: Nikita Leshenko <[email protected]>

    company-tng: Supress post-completion (#731)
    
    As discussed in #731, most post completions modify the buffer so the 
resulting
    text is different from the text that was previewed in company-tng, creating 
a
    surprising transition. For now we decided to disable post-completions 
entirely
    when using company-tng.
---
 company-tng.el | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

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

Reply via email to