branch: externals/valign
commit d4f51412af8248fa64ce0d60b4ed6f93c3e75550
Author: Yuan Fu <[email protected]>
Commit: Yuan Fu <[email protected]>
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 \" \").