Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 panic associated with side-by-side wrapping operations #802

Closed
dandavison opened this issue Nov 27, 2021 · 1 comment · Fixed by #803
Closed

🐛 panic associated with side-by-side wrapping operations #802

dandavison opened this issue Nov 27, 2021 · 1 comment · Fixed by #803

Comments

@dandavison
Copy link
Owner

dandavison commented Nov 27, 2021

delta 0.10 has introduced a regression as reported by @alerque in #794 (comment) : a panic can be triggered by a colorMoved line under side-by-side cc @th1000s .

Using diff-codes.txt

delta --no-gitconfig --side-by-side < diff-codes.txt

Triggering the bug depends on terminal size: in the following output t1 is the syntax_style_sections string concatenation and t2 is the diff_style_sections string concatenation.

[src/wrapping.rs:292] t1 = "As I swore in my wrath, 'They shall not enter my rest.'\"\n"
[src/wrapping.rs:293] t2 = "As I swore in my wrath, 'They shall not enter my rest.'\""
thread 'main' panicked at 'String mismatch encountered while superimposing style sections: '↵' vs '↴'', src/paint.rs:869:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
@dandavison
Copy link
Owner Author

dandavison commented Nov 27, 2021

The bug is related to the fact that, while both line and raw_line start off with no terminating newline character:

[src/handlers/hunk.rs:73] &self.line = "+As I swore in my wrath, 'They shall not enter my rest.'\""
[src/handlers/hunk.rs:74] &self.raw_line = "\u{1b}[1;36m+\u{1b}[m\u{1b}[1;36mAs I swore in my wrath, 'They shall not enter my rest.'\"\u{1b}[m"

Later on, during side-by-side wrapping, a newline has been appended to the "syntax" version of the line (which derives from line) but is missing from the "diff" version of the line (which derived from raw_line):

[src/wrapping.rs:292] t1 = "As I swore in my wrath, 'They shall not enter my rest.'\"\n"
[src/wrapping.rs:293] t2 = "As I swore in my wrath, 'They shall not enter my rest.'\""

This difference is not present at tag 0.9.2.

dandavison added a commit that referenced this issue Nov 27, 2021
Append newline character when preparing raw line

Fixes #802
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 a pull request may close this issue.

1 participant