Previously we assumed that line numbers always required 4 characters to
display (3 digits plus a space). This should be calculated properly
and was probably a placeholder value when testing the original
implementation.
Instead, use the actual width of the rendered line numbers.
Instead of considering the column width for the large line number in
the hunk, consider the largest line number from all hunks for this
file.
Fixes#753
This is perf neutral for the usual benchmarks (where diffing is the
bottleneck, not display) and only a small (0.4% instruction count
increase) on the huge_cpp_1.cpp test files.
I have cargo configured to have a global target directory (in my case,
at /tmp/cargo). The output directory for cargo builds is not guarunteed
to be at ./target.
This could alternatively be solved by the user with strange defaults
(me) making a symlink like `ln -s /tmp/cargo ./target`, which doesn't
require having `jq` installed.
elvish: less highlighted as bold, seems like a small regression
hcl: not highlighting variables in bold now, a small regression
smali: more stuff in bold overall, but no longer the method name in bold
StringIgnoringNewline caused crashes in code that assumed that two
equal values would hav the same string length.
This reverts 86612798ad. A better
approach would be to normalise line endings before diffing, but
additionally print whether files have/lack trailing newlines.
Fixes#755
Input cleaning should happen before we diff the content, not during
display. Previously display would crash due to line numbers
referencing the line that had been stripped.
Fixes#713Fixes#739Fixes#742
We rely on being able to split lines and rejoin them to obtain the
original string. `str::lines()` in the Rust stdlib does not have this
property.
This was causing crashes in word-diffing on textual diffing, where
code paths differed on the number of lines they thought a string had.
This was broken in 8b842387a1.
Fixes#688.