GNU bug report logs -
#76008
31.0.50; visual-wrap-prefix-mode miscalculates prefix width when scaling text
Previous Next
Reported by: Kévin Le Gouguec <kevin.legouguec <at> gmail.com>
Date: Sun, 2 Feb 2025 12:04:02 UTC
Severity: normal
Tags: patch
Found in version 31.0.50
Done: Jim Porter <jporterbugs <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
Jim Porter <jporterbugs <at> gmail.com> writes:
> On 2/2/2025 4:03 AM, Kévin Le Gouguec wrote:
>> I believe the cause lies in visual-wrap--content-prefix; empirically the
>> attached patch shows good results on this reproducer, but I landed on it
>> more by trial-and-error than by rational analysis, so it may be
>> incorrect or suboptimal (e.g. there may be better text-scale or
>> string-width APIs to use).
>
> Thanks. I think the issue here is actually that the display spec for the "average space" was wrong. It used a plain number for the width of the specified space, which means "N times the normal character width for the buffer", but we want "N times the normal character width for the *current face*".
💡
> Could you try this patch?
It does fix the reproducer, thanks!
> ----------------------------------------
>
> diff --git a/lisp/visual-wrap.el b/lisp/visual-wrap.el
> index 1691ba9c500..f2a186ce320 100644
> --- a/lisp/visual-wrap.el
> +++ b/lisp/visual-wrap.el
> @@ -164,7 +164,7 @@ visual-wrap--content-prefix
> ;; units of the font's average-width) large enough to fit the
> ;; first-line prefix.
> (let ((avg-space (propertize (buffer-substring position (1+ position))
> - 'display '(space :width 1))))
> + 'display '(space :width (1 . width)))))
> ;; 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)
This bug report was last modified 106 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.