Wilfred / difftastic

a structural diff that understands syntax 🟥🟩

Home Page:https://difftastic.wilfred.me.uk/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Panic diffing text

davidselassie opened this issue · comments

I'm not totally sure what about the first or second content is causing this, but I'm diffing two Markdown files (which are detected as text files) and get a panic. Using Difftastic 0.56.1 (built with rustc 1.74.1) on Ubuntu.

dsel@lemur ~/panictest (main) [101]> RUST_BACKTRACE=1 difft custom-connectors-old.md custom-connectors-new.md
custom-connectors.md --- Text
12 Also check out some of our built-in custom connectors  12 Also check out some of our built-in custom connectors 
.. in                                                     .. in
13 {py:obj}`bytewax.connectors` and looking at the source 13 {py:obj}`bytewax.connectors` and looking at the source
..  for how they                                          ..  for how they
14 are implemented.                                       14 are implemented.
thread 'main' panicked at /home/dsel/.cargo/registry/src/index.crates.io-6f17d22bba15001f/difftastic-0.56.1/src/display/side_by_side.rs:505:34:
index out of bounds: the len is 14 but the index is 14
stack backtrace:
   0: rust_begin_unwind
             at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/panicking.rs:597:5
   1: core::panicking::panic_fmt
             at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/core/src/panicking.rs:72:14
   2: core::panicking::panic_bounds_check
             at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/core/src/panicking.rs:180:5
   3: difft::display::side_by_side::print
   4: difft::print_diff_result
   5: difft::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

I have tried to make a minimum reproduction. But removing seemingly any of the content from the new file does not cause a panic. Files here:

custom-connectors-new.md
custom-connectors-old.md

I got the same “out of bounds” issue on a ~500 lines csv file interpreted as text, but not at the same place in the code :

thread 'main' panicked at src/display/side_by_side.rs:505:34:
index out of bounds: the len is 462 but the index is 462

Merging into #688, thanks for the report!