🐛 setting a bgcolor for zero style causes crashes
- [x] Please include the raw text output from git, so that we can reproduce the problem.
(You can use
git --no-pagerto produce the raw text output.)
❯ git --no-pager log -p | delta 141 ↲ master[✦]a3e50656[↑✎✭]6h13m
thread 'main' panicked at /Users/slu/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/alloc/src/slice.rs:523:23:
capacity overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
commit a3e5065692f778e03a36eeabea81ac3acae85e51
Author: Steven Lu (MBP M1 Max) <[email protected]>
Date: Fri Jul 25 10:05:15 2025 -0400
fix: Allow color-pane.sh output to be visible
Co-authored-by: aider (vertex_ai/gemini-2.5-pro) <[email protected]>
zshrc
────────────────────────────────────────────────────────────────────
─────────────────────────┐
312: color_tmux_pane() { │
─────────────────────────┘
312¦312│
I figured out after much testing that the WIDTH OF THE TMUX PANE is what controls whether it crashes out or not. Due to this insight I was able to obtain
thread 'main' panicked at /Users/slu/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/alloc/src/slice.rs:523:23:
capacity overflow
stack backtrace:
0: __rustc::rust_begin_unwind
1: core::panicking::panic_fmt
2: alloc::raw_vec::capacity_overflow
3: alloc::raw_vec::handle_error
4: alloc::slice::<impl [T]>::repeat
5: delta::paint::Painter::paint_lines
6: delta::paint::Painter::paint_zero_line
7: delta::handlers::hunk::<impl delta::delta::StateMachine>::handle_hunk_line
8: delta::delta::delta
9: delta::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
and with full:
thread 'main' panicked at /Users/slu/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/alloc/src/slice.rs:523:23:
capacity overflow
stack backtrace:
0: 0x10468ed68 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h92dda645f072dcaf
1: 0x1046ac05c - core::fmt::write::hbc92919d8e8f9a96
2: 0x10468bf50 - std::io::Write::write_fmt::hcee3b5dc9ab531be
3: 0x10468ec1c - std::sys::backtrace::BacktraceLock::print::h0f497abce563e5d2
4: 0x10468fc64 - std::panicking::default_hook::{{closure}}::h62595143a6c21f05
5: 0x10468fab4 - std::panicking::default_hook::hd800536ed1df5085
6: 0x104690744 - std::panicking::rust_panic_with_hook::h1882a30575fbb763
7: 0x104690348 - std::panicking::begin_panic_handler::{{closure}}::h39275ef3005e6337
8: 0x10468f218 - std::sys::backtrace::__rust_end_short_backtrace::h6ede323c05a76849
9: 0x104690018 - __rustc[95feac21a9532783]::rust_begin_unwind
10: 0x1046c402c - core::panicking::panic_fmt::h529fda7ea817ba4f
11: 0x1046c3cdc - alloc::raw_vec::capacity_overflow::h3941a18258a4ea7c
12: 0x1046c3e28 - alloc::raw_vec::handle_error::h08b36af4b863e188
13: 0x104456388 - alloc::slice::<impl [T]>::repeat::h84fabe12163dad36
14: 0x104459418 - delta::paint::Painter::paint_lines::h92688d127d43de4a
15: 0x104458dec - delta::paint::Painter::paint_zero_line::he12f3cfff347613b
16: 0x10446a8fc - delta::handlers::hunk::<impl delta::delta::StateMachine>::handle_hunk_line::h04e30aad84e4243e
17: 0x1044648e4 - delta::delta::delta::hd81c0d8ee124e809
18: 0x104402004 - delta::main::hb69eb6562efe1f7c
19: 0x10440c0cc - std::sys::backtrace::__rust_begin_short_backtrace::h0e45d3419885ad41
20: 0x104495c88 - std::rt::lang_start::{{closure}}::hb314bdb3ed4071fb
21: 0x104684d48 - std::rt::lang_start_internal::hdff9e551ec0db2ea
22: 0x104402fa0 - _main
My delta config in gitconfig:
[delta]
; side-by-side = true
max-line-length = 2048
wrap-max-lines = 10
features = line-numbers decorations
; hyperlinks = true
syntax-theme = zenburn
plus-style = bold syntax "#004000"
plus-non-emph-style = syntax "#002000"
plus-emph-style = bold syntax "#006800"
minus-style = bold syntax "#400000"
minus-non-emph-style = syntax "#200000"
minus-emph-style = bold syntax "#680000"
zero-style = syntax "#1a1a1a" <------ adding this causes crashes; remove and it's stable
[delta "line-numbers"]
line-numbers-left-style = red
line-numbers-right-style = green
line-numbers-minus-style = "bold #7f0000"
line-numbers-plus-style = "bold #007800"
line-numbers-left-format = "{nm:>3}¦"
line-numbers-right-format = "{np:>3}│"
[interactive]
diffFilter = delta --color-only --features=interactive
[core]
editor = nvim
whitespace = cr-at-eol
excludesfile = ~/.gitignore
autocrlf = input
pager = sed 's/\t/→\t/g' | delta --paging=always
I need this because i am starting to set my terminal bgcolor based on project dir because i have too many projects and want to stop issuing commands to the wrong terminal window, so an always visible terminal bgcolor that changes based on that is my current strategy. I just want to make the git-delta diff hunks to have a fixed background color so that a terminal background that is reddish or greenish doesn't render diffs completely unreadable.
Thanks for you report, fixed by #1916
phenomenal thank you. A much needed fix for me! Closing because you sound trustworthy.
@th1000s did this fix get taken back out in 0.18? i tested 0.18.0, 0.18.1 and 0.18.2 by now (on linux) and still seeing this issue. got it working well in 0.17 in another linux box but i'm not able to even build 0.17 (???!):
❯ cargo install --locked [email protected] 141 ↲ master[✦]dab20a0[✭]4m
Updating crates.io index
Installing git-delta v0.17.0
Updating crates.io index
warning: package `iana-time-zone v0.1.59` in Cargo.lock is yanked in registry `crates-io`, consider running without --locked
Updating crates.io index
Compiling libc v0.2.153
Compiling proc-macro2 v1.0.75
Compiling unicode-ident v1.0.12
Compiling rustix v0.38.28
Compiling pkg-config v0.3.28
Compiling memchr v2.7.1
Compiling serde v1.0.194
Compiling cfg-if v1.0.0
Compiling bitflags v2.4.1
Compiling heck v0.4.1
Compiling autocfg v1.1.0
Compiling utf8parse v0.2.1
Compiling linux-raw-sys v0.4.12
Compiling vcpkg v0.2.15
Compiling anstyle-query v1.0.2
Compiling anstyle-parse v0.2.3
Compiling anstyle v1.0.4
Compiling regex-syntax v0.8.2
Compiling itoa v1.0.10
Compiling colorchoice v1.0.0
Compiling clap_lex v0.6.0
Compiling anstream v0.6.5
Compiling strsim v0.10.0
Compiling num-traits v0.2.17
Compiling equivalent v1.0.1
Compiling tinyvec_macros v0.1.1
Compiling crc32fast v1.3.2
Compiling thiserror v1.0.56
Compiling rand_core v0.6.4
Compiling powerfmt v0.2.0
Compiling aho-corasick v1.1.2
Compiling hashbrown v0.14.3
Compiling siphasher v0.3.11
Compiling rand v0.8.5
Compiling quote v1.0.35
Compiling phf_shared v0.11.2
Compiling deranged v0.3.11
Compiling tinyvec v1.6.0
Compiling syn v2.0.48
Compiling serde_json v1.0.111
Compiling adler v1.0.2
Compiling once_cell v1.19.0
Compiling safemem v0.3.3
Compiling terminal_size v0.3.0
Compiling clap_builder v4.4.12
Compiling indexmap v2.1.0
Compiling log v0.4.20
Compiling time-core v0.1.2
Compiling ryu v1.0.16
Compiling line-wrap v0.1.1
Compiling phf_generator v0.11.2
Compiling miniz_oxide v0.7.1
Compiling time v0.3.31
Compiling jobserver v0.1.27
Compiling quick-xml v0.31.0
Compiling same-file v1.0.6
Compiling unicode-normalization v0.1.22
Compiling semver v1.0.21
Compiling cc v1.0.83
Compiling linked-hash-map v0.5.6
Compiling base64 v0.21.5
Compiling bitflags v1.3.2
Compiling unicode-bidi v0.3.14
Compiling bytemuck v1.14.0
Compiling percent-encoding v2.3.1
Compiling yaml-rust v0.4.5
Compiling regex-automata v0.4.3
error[E0282]: type annotations needed for `Box<_>`
--> /home/slu/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/time-0.3.31/src/format_description/parse/mod.rs:83:9
|
83 | let items = format_items
| ^^^^^
...
86 | Ok(items.into())
| ---- type must be known at this point
|
help: consider giving `items` an explicit type, where the placeholders `_` are specified
|
83 | let items: Box<_> = format_items
| ++++++++
Compiling form_urlencoded v1.2.1
Compiling idna v0.5.0
Compiling rgb v0.8.37
Compiling flate2 v1.0.28
Compiling walkdir v2.4.0
Compiling lazy_static v1.4.0
Compiling std_prelude v0.2.12
For more information about this error, try `rustc --explain E0282`.
error: could not compile `time` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
error: failed to compile `git-delta v0.17.0`, intermediate artifacts can be found at `/tmp/cargo-installAm2qLe`.
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.
tested on macos. installing git-delta to get 0.18.2 reintroduces the error.
looks like i still need to install specifying the main branch, or something. maybe the fix fell out of main branch, but it worked earlier.
edit: i'm able to confirm that the main branch (cargo install --git https://github.com/dandavison/delta --branch main git-delta) fixes the error (and on both macos and linux), so i don't understand why the recent releases don't include the fix given it was merged into main on aug 2.