[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#27427: 26.0.50; Native line numbers lead to display error in company

From: Dmitry Gutov
Subject: bug#27427: 26.0.50; Native line numbers lead to display error in company-mode popup
Date: Fri, 14 Jul 2017 02:04:21 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:54.0) Gecko/20100101 Thunderbird/54.0

On 6/26/17 1:56 AM, Dmitry Gutov wrote:
On 6/25/17 8:57 PM, Eli Zaretskii wrote:

Should be fixed now.

Thanks, both cases are working well now.

...and either something changed before the merge into master, or I tested the result poorly. Probably the latter.

What doesn't work well is that the popup "background" gets displaced to the left by the width of the numbers column, when rendered using the popup overlay. Background meaning the contents of all the lines behind the popup. And that happens because the line number glyphs are gone for those specific lines, and we can't pad them without knowing the width of the numbers column.

Now, I've come upon this idea of a trivial patch. What do you think, Eli? It seems to work perfectly, even though I'm struggling to understand how this might happen under the covers. Is it brittle?

We bind display-line-numbers to nil around the call to posn-at-point, so that it calculates the column value that we want. I imagine there's some extra redisplay work involved, but it still turns out to be faster than calling posn-at-point twice.

diff --git a/company.el b/company.el
index f361bb7..869c5de 100644
--- a/company.el
+++ b/company.el
@@ -835,7 +835,8 @@ means that `company-mode' is always turned on except in `message-mode' buffers."
     (cons (+ col (window-hscroll)) row)))

 (defun company--col-row (&optional pos)
-  (company--posn-col-row (posn-at-point pos)))
+  (let (display-line-numbers)
+    (company--posn-col-row (posn-at-point pos))))

 (defun company--row (&optional pos)
   (cdr (company--col-row pos)))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]