emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/valign d4f5141 098/198: Workaround line-number bug


From: Stefan Monnier
Subject: [elpa] externals/valign d4f5141 098/198: Workaround line-number bug
Date: Tue, 1 Dec 2020 18:19:25 -0500 (EST)

branch: externals/valign
commit d4f51412af8248fa64ce0d60b4ed6f93c3e75550
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>

    Workaround line-number bug
    
    When display-line-number-mode is on, the result of
    window-text-pixel-size is inaccurate.
    
    * valign.el (valign--pixel-width-from-to): Add workaround.
---
 valign.el | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/valign.el b/valign.el
index 4d73b98..99392ae 100644
--- a/valign.el
+++ b/valign.el
@@ -157,8 +157,12 @@ The buffer has to be in a live window.  FROM has to be 
less than TO.
 Unlike ‘valign--glyph-width-at-point’, this function can properly
 calculate images pixel width.  Valign display properties must be
 cleaned before using this."
-  (car (window-text-pixel-size
-        (get-buffer-window (current-buffer)) from to)))
+  (- (car (window-text-pixel-size
+           (get-buffer-window (current-buffer)) from to))
+     ;; FIXME: Workaround.
+     (if (bound-and-true-p display-line-numbers-mode)
+         (line-number-display-width 'pixel)
+       0)))
 
 (defun valign--skip-space-backward ()
   "Like (skip-chars-forward \" \").



reply via email to

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