summaryrefslogtreecommitdiffstats
path: root/src/wrapping.rs
AgeCommit message (Collapse)Author
2023-02-28Fix clippy warnings (#1298)nickelc
* Fix clippy warnings - `clippy::uninlined_format_args` * Fix clippy warnings - `clippy::clone_on_copy` - `clippy::explicit_auto_deref` - `clippy::iter_cloned_collect` - `clippy::map_clone` - `clippy::needless_borrow` - `clippy::needless_lifetimes` - `clippy::needless_return` - `clippy::redundant_clone` - `clippy::redundant_field_names` - `clippy::seek_to_start_instead_of_rewind` - `clippy::unnecessary_cast` - `clippy::unused_unit`
2022-12-03try fix bad alignment in unicode (#1144) (#1145)Sheldon Nico
* try fix bad alignment in unicode (#1144) * use width instead of count in wrap_line * fix fmt * 3 tests do not need fail * fix tests Co-authored-by: Thomas Otto <th1000s@posteo.net>
2022-03-14Move wrapping logic and utilities into wrapping moduleDan Davison
2022-01-18Center Align numbers right-ish (#883)Thomas Otto
There is no such thing as "Center Align" with discrete terminal cells. In some cases a decision has to be made whether to use the left or the right cell, e.g. when centering one char in 4 cells: "_X__" or "__X_". The format!() center/^ default is left, but when padding numbers these are now aligned to the right if required. Strings remain left-aligned.
2022-01-04Make Config cloneable for DeltaTest, store as Cow<Config> thereThomas Otto
Only cloneable when testing, the types git2::Config and git2::Repository in GitConfig contain C pointers and can't really be cloned.
2022-01-04DeltaTest improvements (#876)Wayne Davison
* DeltaTest improvements - Added .expect_contains(), .expect_raw_contains(), and .expect_contains_once() member functions to DeltaTestOutput. These functions also output some helpful debug info when the assert fails. - Separated .with_config_and_input() into .with_config() and (the tweaked) .with_input(). - Made .with_config() create a DeltaTest object (like .with() does). - Renamed .with() as .with_args(). - Moved .explain_ansi() from DeltaTestOutput to DeltaTest, which must now be called prior to .with_input() since the latter stashes off both the raw_output & the processed output in the object. - Changed .expect() and .expect_skip() to return Self so that they can continue a chain of multiple expect calls (e.g. a series of partial matches with different skip values). - The processed output text can be accessed via `test_obj.output` (see also `test_obj.raw_output`). - Renamed .expect_skip() to .expect_after_skip(). - Changed .expect() to start at the first line. - Added .expect_after_header() that works like the old .expect(). - Renamed lines_match() to assert_lines_match() and made it match all lines (no skip number). - Added assert_lines_match_after_skip() to work like the old lines_match() function, but with the .expect_after_skip() arg order. - Converted some old-style tests into DeltaTest style tests. - Renamed set_cfg as set_config
2021-12-14Line state refactor (#851)Dan Davison
* Refactor: compute raw line and new line state
2021-12-07Fixed some test clippysThomas Otto
Note that currently `cargo clippy --tests` is not checked by the CI runs
2021-12-07Add DeltaTest to speed up adding and fixing testsThomas Otto
Using a syntax similar to the builder pattern: `DeltaTest::with([config options]).with_input(DIFF).expect(lines)` plus `.explain_ansi()` to pretty-print ansi codes and `.inspect()` to print the to-be-tested output. Rewrite a few tests using it and add ansi tests for --line-fill-method=<spaces|ansi>
2021-12-05Display merge conflictsDan Davison
2021-12-05Handle combined diff formatDan Davison
With this commit combined diff format (https://git-scm.com/docs/git-diff#_combined_diff_format) is handled appropriately. However, there is no special handling of merge conflict markers. Fixes #189, #736
2021-11-27Refactor: further isolate side-by-side implementation (#801)Dan Davison
2021-11-26Refactor: rename: LineSegments -> LineSectionsDan Davison
2021-11-10Remove +/- line prefix instead of substituting a spaceThomas Otto
Simplifies line handling and printing by removing a "magical" 1-offset previously required in various locations. Now explicitly prepend "" in `tokenize()`.
2021-10-25Re-enable ANSI fill by equalizing panel sizesThomas Otto
Make the two panels in side-by-side use the full terminal width by inserting an extra space in the center between the panels if the width is odd and ANSI filling is enabled. Fall back to spaces when the output is not to a terminal.
2021-10-16Change PlusMinus to the correct MinusPlus, add documentationThomas Otto
2021-10-16Tests: store length of skipped header separatelyThomas Otto
2021-10-16Add inline-hint-style option and use for side-by-side wrap symbolsDan Davison
2021-10-16Add side-by-side line wrappingThomas Otto
If the current line does not fit into the panel, then it is not truncated but split into multiple lines. A wrapping symbol is placed at the end of the line. If the new line is short enough, it is right-aligned. Wrapping is limited to a certain number of lines (--wrap-max-lines), if this is exceeded the line is truncated by a now highlighted truncation symbol. To disable wrapping set this value to 0.