Skip to content

feat: implement box ol and box ul ol decoration styles - #2215

Open
VXNCXNX wants to merge 1 commit into
dandavison:mainfrom
VXNCXNX:feat/box-overline-decorations
Open

feat: implement box ol and box ul ol decoration styles#2215
VXNCXNX wants to merge 1 commit into
dandavison:mainfrom
VXNCXNX:feat/box-overline-decorations

Conversation

@VXNCXNX

@VXNCXNX VXNCXNX commented Aug 14, 2026

Copy link
Copy Markdown

Fixes #214.

What was missing

0d593c2 made decoration styles compose, but box ol and box ul ol were left as TODOs that fell through to a plain box:

DecorationStyle::BoxWithOverline(style) => {
    // TODO: not implemented
    (Box::new(write_boxed), true, style)
}

So --commit-decoration-style='box ol' silently rendered the same thing as box, with no error to tell you the style wasn't supported.

The fix

write_boxed_partial hardcoded as the top-right corner. It now takes an overline: bool that selects or ┬─, and that flag threads up through write_boxed_with_horizontal_whisker. The four public draw functions become thin wrappers over two shared bodies, so box/box ol and box ul/box ul ol differ only in that flag rather than in duplicated drawing code.

Result — box ol is the vertical mirror of box ul:

box                 box ul              box ol              box ul ol
──────────────┐     ──────────────┐     ──────────────┬─    ──────────────┬─
commit 94907c │     commit 94907c │     commit 94907c │     commit 94907c │
──────────────┘     ──────────────┴─    ──────────────┘     ──────────────┴─

Tests

You'd already written the expected output for both cases as #[ignore]d tests (test_commit_style_box_ol, test_file_style_box_ol). Those are the spec here — I implemented against them and removed the #[ignore], without touching a single assertion string or width argument. box ul ol had no pre-written test, so I added two modeled exactly on the ol pair.

cargo test:        442 passed; 0 failed; 6 ignored   (was 440 passed; 8 ignored)
cargo fmt --check: clean
cargo clippy:      no new warnings (4 pre-existing in src/utils/process.rs)

What I checked beyond the tests

  • No regression on the two styles that already worked. Captured raw output (ANSI codes included) for box and box ul at widths 64/10/1/variable, plus raw and bold modes, before and after the change: 12/12 byte-identical.
  • No underflow at narrow widths. box ol never touches line_width; box ul ol reuses the existing guarded line_width - box_width - 1. Ran all four styles at --width=10 and --width=1 against a 46-char commit line, exit 0, no panic.
  • Heavy/light stays correct. DOWN_HORIZONTAL is destructured in the same is_bold branch as the other glyphs, so it can't desync. Bold renders .
  • --commit-style raw still works with both new styles.

One thing worth your call: the overline whisker is a fixed 2 chars (┬─) regardless of terminal width, since box-family functions ignore line_width. That's what the ignored test asserts, and it matches the existing _line_width: &Width, // ignored precedent, but if you'd rather the overline whisker extend to fill the width like the underline one does, that's a small follow-up.

Both variants existed in DecorationStyle but fell through to a plain box behind a TODO, so the overline whisker was silently dropped. Parameterize the top-right corner of write_boxed_partial so it can be a whiskered joint, and wire the two arms to it. box ol is now the vertical mirror of box ul, and box ul ol carries a whisker on both edges. The two pre-written tests for this are no longer ignored, and box ul ol gets equivalent coverage. Fixes dandavison#214.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 Support 'box ol' composed decoration

1 participant