mirror of
https://github.com/dandavison/delta.git
synced 2026-10-12 02:12:41 +00:00
* Include the mode change in the width of file header decorations If the mode of a file changes, delta adds the change to the file header, as in "src/delta.rs (mode +x)". With file-decoration-style "box", the top and bottom edges of the box cover only "src/delta.rs ", so they are too short for the text. With --width=variable, the underline is too short in the same way. This happens because the draw functions measure the text before they add the mode change to it. Measure the text that the draw functions write instead. Add text_to_write() for this. It returns the raw text, or the painted text with the mode change, and all draw functions now use it. The box still has two spaces before "(mode +x)". This comes from the space that callers add to the text for boxes, and this commit doesn't change it. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * Keep decorations within the width given by --width If a file path or a hunk header is wider than the terminal, its decoration is drawn wider than the terminal too. The terminal then wraps the lines of the decoration, and the header becomes hard to read (#2043). This happens often in narrow terminals, and in lazygit, where the diff gets only part of the screen. The decorations grow with the text. An underline or overline is as wide as --width, or as wide as the text if the text is wider. A box is always as wide as the text. If --width isn't set, delta uses the terminal width. Draw underlines and overlines exactly as wide as --width. Delta doesn't wrap their text; the terminal still does this. If the text of a box is too wide, wrap it inside the box so that the box is as wide as --width. Lines break at any character, like they do in the terminal, and each line keeps a space before the right edge of the box. Add ansi::wrap_str() for the wrapping. If a style or a hyperlink is active where a line ends, wrap_str() ends it there and starts it again on the next line. With --width=variable, decorations still extend to the end of the text, as the help text for --width says. Three tests used text that is wider than the test width of 43 columns, and they expected the decorations to grow with it. Give them a --width that fits the text, so they still test the case they were written for. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * Explain why wrap_str does not reuse wrapping::wrap_line * Merge text_to_write into paint_text, its only caller * Fix submodule metadata snapshot: underlines no longer exceed --width Run tests with: env -u OSC1717 cargo test --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]> Co-authored-by: Dan Davison <[email protected]>