dandavison / delta

A syntax-highlighting pager for git, diff, grep, and blame output
https://dandavison.github.io/delta/
MIT License
21.32k stars 358 forks source link

šŸ› Panic in `src/paint.rs:907` for a valid patch with syntax highlight and line wrapping #1726

Open ilya-bobyr opened 1 week ago

ilya-bobyr commented 1 week ago

With the following patch:

--- a.rs
+++ b.rs
@@ -10,3 +10,3 @@
  a
  The ';' character on this line must be exactly in the very last position on the right ----------> ;
  b

I see an assertion failure, if the ; happens to be exactly in the very last position on the screen. It also needs to be a complete patch, when there are two sides that need to be output. It does not matter what is on the left side, or that it has not actual updates in it. Syntax also matters. If I change a.rs/b.rs to a.txt/b.txt the panic goes away. Here is a complete output:

āÆ cat broken.patch | RUST_BACKTRACE=1 delta --wrap-max-lines=2
thread 'main' panicked at /home/ilya/.cargo/registry/src/index.crates.io-6f17d22bba15001f/git-delta-0.17.0/src/paint.rs:907:17:
String mismatch encountered while superimposing style sections: ';' vs 'ā†“'
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: delta::paint::superimpose_style_sections::superimpose_style_sections
   3: delta::paint::Painter::paint_line
   4: delta::features::side_by_side::paint_zero_lines_side_by_side
   5: delta::paint::Painter::paint_zero_line
   6: delta::handlers::hunk::<impl delta::delta::StateMachine>::handle_hunk_line
   7: delta::delta::delta
   8: delta::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Ī” a.rs āŸ¶   b.rs
ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€

ā”€ā”€ā”€ā”€ā”€ā”€ā”
ā€¢ 10: ā”‚
ā”€ā”€ā”€ā”€ā”€ā”€ā”˜
ā”‚ 10 ā”‚ a                                                                                                   ā”‚ 10 ā”‚ a
th1000s commented 1 week ago

I was also unable to reproduce this, see #1724 :frowning_face:

ilya-bobyr commented 23 hours ago

This one also reproduces for me with the default configuration:

āÆ vim broken.patch
# Paste patch from GitHub, save and exit

āÆ RUST_BACKTRACE=1 HOME=/ delta --no-gitconfig --side-by-side < broken.patch
thread 'main' panicked at /home/ilya/.cargo/registry/src/index.crates.io-6f17d22bba15001f/git-delta-0.17.0/src/paint.rs:907:17:
String mismatch encountered while superimposing style sections: ';' vs 'ā†“'
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: delta::paint::superimpose_style_sections::superimpose_style_sections
   3: delta::paint::Painter::paint_line
   4: delta::features::side_by_side::paint_zero_lines_side_by_side
   5: delta::paint::Painter::paint_zero_line
   6: delta::handlers::hunk::<impl delta::delta::StateMachine>::handle_hunk_line
   7: delta::delta::delta
   8: delta::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

a.rs āŸ¶   b.rs
ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€

ā”€ā”€ā”€ā”€ā”
10: ā”‚
ā”€ā”€ā”€ā”€ā”˜
ā”‚ 10 ā”‚ a                                                                                                  ā”‚ 10 ā”‚ a

āÆ echo $COLUMNS
212

I've installed delta with cargo install delta. So, I think, my binary is matching the 0.17.0 release. I also started noticing this issue only after a recent update.

I'm on the latest Ubuntu, with Alacritty and tmux, but I doubt that it matters.