]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix 'min-width' calculation in 'visual-wrap-prefix-mode'
authorJim Porter <jporterbugs@gmail.com>
Sat, 19 Oct 2024 23:12:43 +0000 (16:12 -0700)
committerEshel Yaron <me@eshelyaron.com>
Tue, 22 Oct 2024 19:00:22 +0000 (21:00 +0200)
* lisp/visual-wrap.el (visual-wrap--content-prefix): Remove 'min-width'
before computing the pixel width to avoid miscalculation (bug#73882).

(cherry picked from commit 81a5beb8af020e4c92a77d61c8aa5e637e2dc945)

lisp/visual-wrap.el

index 76276c0f4742b10ece0b68377898b800c4ae3de6..fa128d287a4e2307996f11730e0c1e9e3b626783 100644 (file)
@@ -165,9 +165,12 @@ PREFIX was empty."
     ;; first-line prefix.
     (let ((avg-space (propertize (buffer-substring position (1+ position))
                                  'display '(space :width 1))))
-        (max (string-width prefix)
-             (ceiling (string-pixel-width prefix (current-buffer))
-                      (string-pixel-width avg-space (current-buffer))))))))
+      ;; Remove any `min-width' display specs since we'll replace with
+      ;; our own later in `visual-wrap--apply-to-line' (bug#73882).
+      (add-display-text-property 0 (length prefix) 'min-width nil prefix)
+      (max (string-width prefix)
+           (ceiling (string-pixel-width prefix (current-buffer))
+                    (string-pixel-width avg-space (current-buffer))))))))
 
 (defun visual-wrap-fill-context-prefix (beg end)
   "Compute visual wrap prefix from text between BEG and END.