Commit Graph

1259 Commits

Author SHA1 Message Date
Dan Davison 823e852583 Fall back to diff if git diff fails due to lack of support for process substitution 2024-08-04 09:15:37 -04:00
Dan Davison de7d32013b Use enum 2024-08-04 09:03:11 -04:00
Dan Davison 7acc55aa17 Revert "wip"
This reverts commit 915ff02134.
2024-08-04 08:58:30 -04:00
Dan Davison 915ff02134 wip 2024-08-04 08:49:58 -04:00
Dan Davison 17784285a1 Don't print entire --help text 2024-08-04 08:27:23 -04:00
Dan Davison 2bc8444546 Set unified context iff needed 2024-08-02 08:01:59 -04:00
Dan Davison dbfa90ffbf Improve behaviour on error of external diff process 2024-08-01 22:04:21 -04:00
Dan Davison c8bd7f0544 Suggestions from code review 2024-08-01 21:46:58 -04:00
Dan Davison 47a6177e00 Implement --diff-args 2024-08-01 21:46:56 -04:00
Thomas Otto f441d4d083 Fix build for rust 1.80
Upgrade "time" (and its dependency chain rooted at "plist"), the previous
version did not build with 1.80.

Tell the new 'unexpected_cfgs' lint that 'tarpaulin_include' is okay

Mark one clippy lint as a false positive
2024-08-01 21:40:55 -04:00
Thomas Otto e0274867cd Use angle bracket around <urls>, regenerate help output markdown 2024-08-01 21:40:55 -04:00
Thomas Otto d2765a489e Wrap --help output and use pager
Tell clap to not wrap output, append `after_long_help()` (with matching
ansi codes in this section), then manually wrap the result.

The help output is now paginated if writing to a terminal.

All code paths flow back to main(), so an invoked pager is properly
waited for (by the OutputType drop impl).
2024-08-01 21:40:55 -04:00
Thomas Otto 6ef193250a Add wrap function for --help output
Unicode and somewhat ANSI aware, can add indentation (skippable) and
can also skip wrapping lines by using configurable magic prefixes.
2024-08-01 21:40:55 -04:00
Thomas Otto 546e0ed412 Make drop impl of OutputType more prominent 2024-08-01 21:40:55 -04:00
Thomas Otto c5f7428edd OutputType: PagerCfg and oneshot_write
Use new, smaller PagerCfg instead of the full Config, as for
pager output only 3 variables are relevant.

oneshot_write() can be used to write paginated output, usually
before exiting.
2024-08-01 21:40:55 -04:00
Thomas Otto 21695da83a Add --max-syntax-highlighting-length, set to 400
--max-line-length increased to 3000, highlighting now stops after 400
characters. In that case the highlighting may be incorrect until it
is reset for the next hunk.
2024-07-22 02:54:31 +01:00
Thomas Otto 6205118b85 Add truncate_str_short() which always returns a prefix of the input
Document that the input of `truncate_str()` may be cut on a double width
char ("fullwidth") - then the output is no longer a prefix of the input.

`truncate_str_short()` could be faster by not constructing the result and
instead only returning an index, but it will be used in rare edge cases so
reusing existing logic is good enough.

Common code moved to `truncate_str_impl()`.

Assume (with fallback) that graphemes are at most 2 wide.
Fewer allocations.
Tests.
2024-07-22 02:54:31 +01:00
Tau Gärtli 841d559a84 Disable light mode detection in tests (#1765) 2024-07-21 20:41:23 -04:00
Justin Su 26d764a209 Fix copy-paste typo (#1767)
Accidentally introduced in #1744
2024-07-17 09:33:26 -04:00
Justin Su 07e951db22 Add missing --file-*-label option to --navigate docs (#1744)
Also sort the options alphabetically
2024-07-17 05:28:53 -04:00
Justin Su f2c43ae0f3 Fix a typo to make Catppuccin Latte detected as light theme (#1745)
Also sort `LIGHT_SYNTAX_THEMES`
2024-07-17 05:18:00 -04:00
Thomas Otto 048ae76aaa Make less version >= 633 behave like previous versions wrt. Nerd Fonts
Sets `LESSUTFCHARDEF` (unless already present), a new env var introduced
by this less version to always print characters from the Private Use Area
of Unicode as-is, even if the terminal does not understand them.
2024-07-17 10:13:59 +01:00
Tau Gärtli c4803e6825 Update terminal-colorsaurus (#1699)
* Update terminal-colorsaurus to 0.4.0

* Update `terminal-colorsaurus` with bugfix

> * 🐛 Fixed `OSC 11` response being visible to users of GNU Screen
     by detecting Screen and erroring before sending any control sequences (bash/terminal-colorsaurus#16).

* Update `terminal-colorsaurus` to 0.4.3
2024-07-16 13:39:59 -04:00
Thomas Otto 5d538b2303 Make relative-paths work with binary files
`relativize_path_maybe()` was not called in this case. Added
test and converted a few existing ones to insta.
2024-07-09 00:00:18 +01:00
Thomas Otto 995dc41525 Make relativize_path_maybe directly update the path argument
This simplifies the call sites.
Also skip updating if the path is already absolute, and handle
'/dev/null' on Windows so it is no longer converted to '\dev\null'.
2024-07-09 00:00:18 +01:00
Thorou 716fa79500 Fix panic when blame-palette is empty (#1737)
* Fix panic when blame-palette is empty

* Move check to config.rs
2024-07-08 03:42:59 -04:00
Thomas Otto d7a22a7cf9 tests: set terminal width to 43 (#1741)
Make tests more deterministic by not allowing them
to "see" the current terminal width.
2024-07-07 04:33:15 -04:00
Thomas Otto 096941f77f tests: add insta for snapshot testing (#1739)
Insta makes writing new tests or performing changes which update the
expected value(s) easier. The new reference data can be reviewed
and inserted/updated automatically by `cargo insta review` (after
`cargo install cargo-insta`, but that tool is optional).

The snapshots are stored inline using the `@""` syntax and not in
separate files because the delta test output is small and designed to
be human readable.

See https://insta.rs/#hello-snapshot-testing
and https://docs.rs/insta/1.39.0/insta/
2024-07-06 10:35:06 -04:00
Thomas Otto f5b37173fe Don't read git files when --no-gitconfig is given + unused variables (#1728)
* Fix unused variables

* Don't read git files when --no-gitconfig is given

Despite starting delta with `--no-gitconfig`, strace still shows
that `.git/config` etc. files are accessed. By no longer doing
that it is very clear that no config options are read from there.
2024-06-24 13:26:28 -04:00
Dan Davison d995bf76cf clippy (#1686) 2024-05-04 10:00:44 -04:00
Thomas Otto 711353b4dd tests: prevent parallel env var access (#1681)
`env::set_var` is not-yet-unsafe, and here tests fail
because a var is already set by a second test while the first one
is still running.

`cargo test -- test_env` with sufficient (auto detected) parallelism
triggers this.
2024-05-04 09:45:37 -04:00
Thomas Otto 3b953daac7 Repair --default-language, and highlight using full filename (#1549)
* Fix clippy warnings

* Repair --default-language, and highlight using full filename

Fixed that the "txt" fallback was used instead of --default-language

And when looking for syntax highlighting, keep the filename around
as long as possible.

Using simple custom logic (filename > 4) a Makefile can be highlighted
with make syntax, but a 'cc' or 'ini' file does not get treated like
a *.cc or *.ini file.

Currently the underlying highlighting lib syntect and the sublime syntax
definitions can not make this distinction
(<http://www.sublimetext.com/docs/syntax.html>).
2024-05-04 09:44:39 -04:00
Phillip Wood 4b80dfb04c Stop highlighting unchanged whitespace (#1659)
Fix a regression introduced by feec45b (Fix warning highlight for
trailing whitespace (#1037), 2023-05-17) where trailing space at the end
of an unchanged token is highlighted if the token follows an insertion.
This happens because when the token is split in two to separate trailing
whitespace the two halves end up being tagged with different edit
operations. This can be seen in the test changes in
`test_infer_edits_14` and `test_infer_edits_16` introduced by feec45b
which changed the operation from `PlusNoop` to `Insertion` when
splitting trailing whitespace from unchanged tokens. Fix this by using
the same operation when adding both halves of a split token and
correcting the tests.

Fixes #1658
2024-03-17 10:17:49 -04:00
Pawel Dominiak 34e33673d8 Honor default-language option (#1655)
* Honor default-language option

* Add tests for default-language option

---------

Co-authored-by: Dan Davison <dandavison7@gmail.com>
2024-03-16 10:10:10 -04:00
Tau 2f76c56d91 Detect Dark/Light Mode from Terminal (#1615) 2024-03-12 11:05:44 -04:00
Pawel Dominiak 9b775ecd36 Preserve "Binary files" line in color_only mode (#1649)
Closes #320
2024-03-12 07:53:12 -04:00
Dan Davison d41d02d10f Fix clippy complaints 2024-03-04 16:34:32 -05:00
Damir Vandic 6978da4b53 Add Catppuccin latte to light syntax themes (#1573) 2024-03-02 12:06:00 -05:00
Paul 977f89ae0d Fix headers of modified binary files, closes #1621 (#1629) 2024-03-02 09:06:31 -05:00
Josh Triplett f7ae06a5f1 Parse filename unambiguously using color escape sequences (#1634)
* Simplify handle_grep_line via early return

Rather than indenting the entire body of the function twice, return
early if the conditions aren't met.

* Parse filename unambiguously using color escape sequences

`git grep`, by default, emits ANSI color escape sequences around the
filename, separator, and line number. Parse these if available.

This currently assumes the default colors, and will fall back to the
previous parsing if any of the colors have been changed.

Add tests for filenames that previously failed to parse correctly.
2024-03-02 08:41:56 -05:00
Josh Triplett 037665ba37 Switch from vte to anstyle-parse (already used in dependencies) (#1638)
delta already depends indirectly on anstyle-parse through clap. Switch
from vte to anstyle-parse to eliminate a few dependencies.
2024-03-02 08:35:55 -05:00
Dan Davison 084a6d19b2 Accept clippy suggestions (#1632) 2024-02-19 12:56:22 -05:00
Dan Davison e208f4ed52 Bug fix: reset syntax highlighter across grep sections (#1613) 2024-01-20 14:06:03 -05:00
Dan Davison 9f66dc3849 --show-themes exit with error when no themes (#1611)
Fixes #587
2024-01-19 09:21:23 -05:00
Zack Cerza 06b95306ac Make hunk header code fragment display optional (#1568)
Fixes: #1032
2023-11-20 22:18:19 -05:00
plustik 49a99180fe feat: generate completion subcommand (#1561)
* generate-completion subcommand
* add Makefile target and replace completion scripts in repo with generated output
* Add completion to manual
2023-11-19 10:20:52 -05:00
Fritz Rehde dc692ea796 fixed typos (#1553) 2023-11-18 10:11:11 -05:00
Dan Davison 7375f7a165 Add comment in lieu of test coverage for now 2023-08-13 17:28:38 -04:00
Dan Davison f82e00dee3 Support users other than git in github SSH URLs (#1509)
E.g.
org-123456@github.com:temporalio/api.git
2023-08-13 17:26:10 -04:00
Dan Davison ae26b5497c Fix handling of tabs in grep output (#1507)
Fixes #1501
2023-08-12 22:08:54 -04:00