branch: externals/company
commit d77b1428995f6e8d18d1598eaef4480adc9906fa
Author: Dmitry Gutov <[email protected]>
Commit: Dmitry Gutov <[email protected]>

    company-echo-show: Try harder not to resize the minibuffer
    
    Now that it can be active, we have to account for the 'minibuffer-message' 
route
    as well, which unfortunately does no obey message-truncate-lines.
---
 company.el | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/company.el b/company.el
index f6b6c2a85b..2f55b3b74f 100644
--- a/company.el
+++ b/company.el
@@ -4675,9 +4675,18 @@ Delay is determined by `company-tooltip-idle-delay'."
 (defun company-echo-show (&optional getter)
   (let ((last-msg company-echo-last-msg)
         (message-log-max nil)
-        (message-truncate-lines company-echo-truncate-lines))
+        (message-truncate-lines company-echo-truncate-lines)
+        max-len)
     (when getter
       (setq company-echo-last-msg (funcall getter)))
+    (when (and company-echo-truncate-lines
+               (active-minibuffer-window))
+      (setq max-len
+            (- (window-width (minibuffer-window))
+               (buffer-size (window-buffer (minibuffer-window)))
+               4))
+      (when (> (length company-echo-last-msg) max-len)
+        (setq company-echo-last-msg (substring company-echo-last-msg 0 
max-len))))
     ;; 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

Reply via email to