emacs/test/manual
Andrea Alberti ca5e9976b1 Pixel-direct alignment in visual-wrap-prefix-mode (bug#81039)
`visual-wrap--content-prefix' previously returned a column count
computed as

    (max (string-width prefix)
         (ceiling (string-pixel-width prefix) avg-space-width))

with two problems:

* `string-width' ignores `buffer-invisibility-spec', so an invisible
  prefix (hidden ATX markers under `markdown-ts-hide-markup', for
  example) still reserved its character count on line 1 via a
  `min-width' display property, shifting the visible heading right.

* With variable-pitch fonts, rounding the prefix width up to whole
  columns added visible padding whenever the natural width did not
  fall on an exact column boundary.

Return the prefix's natural pixel width via `string-pixel-width'
instead, which accounts for any display transformation applied to
the prefix (invisibility, `display' replacements, text scaling,
proportional fonts).  Drop the `min-width' property from
`visual-wrap--apply-to-line' so line 1 renders at its natural width.
Switch the continuation `wrap-prefix' to a mixed-unit `:align-to'
sum form:

    (space :align-to (+ (PIX) (EXTRA-INDENT . width)))

where PIX is the prefix's pixel width and EXTRA-INDENT is
`visual-wrap-extra-indent' in canonical character widths.  The
display engine resolves each term per the active frame and sums
them, so no Lisp-level unit conversion is needed.

Since `min-width' is no longer installed, the accumulation cycle
that commit 81a5beb8af (bug#73882) worked around cannot recur.
Drop the `min-width' strip from `visual-wrap--content-prefix' and
the `min-width' removal from `visual-wrap--remove-properties'.
Keep `min-width' in `visual-wrap--safe-display-specs' so that
lines where other modes install it are not skipped.

* lisp/visual-wrap.el (visual-wrap--content-prefix): Return pixel
width instead of column count; drop the `min-width' strip.
(visual-wrap--apply-to-line): Drop `min-width' on line 1; use
mixed-unit `:align-to' sum form for the continuation wrap-prefix.
(visual-wrap--adjust-prefix): Handle only string prefixes; the
numeric (pixel) case is now handled inline in `--apply-to-line'
via the mixed-unit `:align-to' sum form.
(visual-wrap--remove-properties): Drop `min-width' removal.
(visual-wrap--safe-display-specs): Add note about `min-width'.
* test/lisp/visual-wrap-tests.el: Update expected `wrap-prefix'
values to the new sum form.
(visual-wrap-tests/invisible-prefix): New test motivated by bug#81039.
(visual-wrap-tests/negative-extra-indent): New test; verify that a
large negative `visual-wrap-extra-indent' produces a valid
wrap-prefix (the display engine clamps the stretch to zero).
* test/manual/visual-wrap-test.el: New file.  Manual test suite
for visual-eyeball verification of prefix alignment behavior.

Reported-by: Andrea Alberti <a.alberti82@gmail.com>
Co-authored-by: Stefan Monnier <monnier@iro.umontreal.ca>
2026-05-26 16:56:32 -04:00
..
cedet ; Add 2026 to copyright years. 2026-01-01 12:54:34 +00:00
etags ; * test/manual/etags/README: Update the procedure for CTAGS.good_update. 2026-01-03 11:30:45 +02:00
indent ; Add 2026 to copyright years. 2026-01-01 12:54:34 +00:00
noverlay ; Add 2026 to copyright years. 2026-01-01 12:54:34 +00:00
BidiCharacterTest.txt Update to Unicode 17.0 2025-09-11 18:00:42 +03:00
biditest.el ; Add 2026 to copyright years. 2026-01-01 12:54:34 +00:00
image-circular-tests.el ; Add 2026 to copyright years. 2026-01-01 12:54:34 +00:00
image-size-tests.el ; Add 2026 to copyright years. 2026-01-01 12:54:34 +00:00
image-tests.el ; Add 2026 to copyright years. 2026-01-01 12:54:34 +00:00
image-transforms-tests.el ; Add 2026 to copyright years. 2026-01-01 12:54:34 +00:00
process-callout-tests.el ; Add 2026 to copyright years. 2026-01-01 12:54:34 +00:00
redisplay-testsuite.el ; Add 2026 to copyright years. 2026-01-01 12:54:34 +00:00
scroll-tests.el ; Add 2026 to copyright years. 2026-01-01 12:54:34 +00:00
visual-wrap-test.el Pixel-direct alignment in visual-wrap-prefix-mode (bug#81039) 2026-05-26 16:56:32 -04:00