branch: externals/company
commit 9d55b02c8c4ca823b31ea5c69efa9f8e5ce92c5b
Author: Dmitry Gutov <dgu...@yandex.ru>
Commit: Dmitry Gutov <dgu...@yandex.ru>

    company-echo-show: Avoid altering echo area unnecessarily
    
    Related:
    
    https://github.com/company-mode/company-mode/issues/588
    https://github.com/company-mode/company-mode/issues/797
    https://debbugs.gnu.org/cgi/bugreport.cgi?bug=62816
---
 NEWS.md    |  3 +++
 company.el | 15 ++++++++++-----
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/NEWS.md b/NEWS.md
index a459a356e5..361e77fc19 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -2,6 +2,9 @@
 
 ## Next
 
+* `company-echo-show` (and related featuers, most importantly,
+  `company-echo-metadata-frontend`) now should stop interfering with the echo
+  area and ElDoc when the current backend returns no `meta`.
 * New user option `company-tooltip-annotation-padding`
   ([#1376](https://github.com/company-mode/company-mode/discussions/1376)).
 * When a snippet name is typed in full, completion does not abort now (only
diff --git a/company.el b/company.el
index 01e89a6d14..bcbe3a5057 100644
--- a/company.el
+++ b/company.el
@@ -3862,13 +3862,18 @@ Delay is determined by `company-tooltip-idle-delay'."
   :package-version '(company . "0.9.3"))
 
 (defun company-echo-show (&optional getter)
-  (when getter
-    (setq company-echo-last-msg (funcall getter)))
-  (let ((message-log-max nil)
+  (let ((last-msg company-echo-last-msg)
+        (message-log-max nil)
         (message-truncate-lines company-echo-truncate-lines))
-    (if company-echo-last-msg
+    (when getter
+      (setq company-echo-last-msg (funcall getter)))
+    ;; Avoid modifying the echo area if we don't have anything to say, and we
+    ;; didn't put the previous message there (thus there's nothing to clear),
+    ;; https://debbugs.gnu.org/cgi/bugreport.cgi?bug=62816#20
+    (if (not (member company-echo-last-msg '(nil "")))
         (message "%s" company-echo-last-msg)
-      (message ""))))
+      (unless (member last-msg '(nil ""))
+        (message "")))))
 
 (defun company-echo-show-soon (&optional getter delay)
   (company-echo-cancel)

Reply via email to