summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2025-08-03Styled zero lines fixmainThomas Otto
With `interactive.diffFilter = delta --color-only` delta is called by e.g. `git add -p`, but in this mode git hides the terminal from the pager. Plus/minus lines correctly use ANSI sequences to paint up to to the end of the line, but zero lines always use spaces. This needs the terminal width, but it is not available for diffFilter. So the fallback of 80 is used, and zero styles did not extend to the full terminal width. Since zero lines are only rarely styled (e.g. via `--zero-style='syntax "#1d1f21" dim'`), this was never noticed. This also crashed delta when a zero line was longer than 80.
2025-08-01Fix diff output when a diff ends with a mode changeThomas Otto
Output can be generated directly via Painter::write, or Painter::output_buffer. The latter must be emit()'ed before the former method can be used again, otherwise the order is incorrect. Tests added. Fixes #1504
2025-07-15Fix clippy errors (#2016)Justin Su
2025-05-02Fix index out of bounds crash for '@@ @@' hunk headerAdam Johnson
2025-01-09clippy 1.84 fixThomas Otto
2024-12-10hyperlink commit hashes of length 7 as wellThomas Otto
2024-12-02Don't keep subcommand stdout aroundThomas Otto
take() and pass it to BufReader so it gets closed when the reader stops. Otherwise on an early pager (EPIPE), and thus delta() exit the feeding subcommand still has an open stdout to write something into and wait()-ing on it hangs.
2024-11-28Support external subcommands: rg, diff, git-show (etc.) (#1769)Thomas Otto
* Support external subcommands: rg, git show, git log (etc.) The possible command line now is: delta <delta-args> [SUBCMD <subcmd-args>] If the entire command line fails to parse because SUBCMD is unknown, then try (until the next arg fails) parsing <delta-args> only, and then parse and call SUBCMD.., its output is piped into delta. Other subcommands also take precedence over the diff/git-diff mode (`delta a b`, where e.g. a=git and b=show), and any diff call gets converted into an external subcommand first. Available are: delta rg .. => rg --json .. | delta delta a b .. => git diff a b .. | delta delta git show .. => git <color-on> show .. | delta and all other git-CMDS, of which add -p, blame, checkout -p, diff, grep, log -p, reflog -p, and stash show -p produce a diff. Because --json is automatically added for `delta rg ..`, it avoids the parsing ambiguities of and is easier to type than `rg .. | delta`. The piping is not done by the shell, but delta, so the subcommands are now child processes of delta. * Set calling process directly because delta started it This info then takes precedence over whatever start_determining_calling_process_in_thread() finds or rather doesn't find. (The simple yet generous SeqCst is used on purpose for the atomic operations.)
2024-11-29clippy 1.83: silence zombie_processes false positiveThomas Otto
But now < 1.83 clippy would complain about an unknown lint, so allow that, too.
2024-11-29clippy 1.83: fix unnecessary_first_then_checkThomas Otto
2024-11-29clippy 1.83: apply explicit lifetimes elisions suggestionsThomas Otto
2024-11-20Allow multiple hyperlinks per lineThomas Otto
Previously only the last commit was linked. Do not link numbers (technically also commits), and stop after finding 12 commits on a line.
2024-11-20testability: add pretty_assertions, git mocksThomas Otto
2024-11-16Support {host} in hyperlinks (#1901)Dan Davison
* Support {host} in hyperlinks * Improve help text
2024-11-15Rename poorly-named variables (#1904)Dan Davison
2024-11-14Honor pager path when checking less version (#1903)Dan Davison
2024-11-09Redundant Option Checks, Unwrap Safety (#1892)shray sharma
Redundant Option Checks, unwrap Safety, unnecessary Lifetimes, Rust often infers lifetimes automatically --------- Co-authored-by: Quied <dexflame3@gmail.com>
2024-11-05Add optional capture-output writer to run_app()Thomas Otto
The output and exit code of run_app() are now testable, used for diff test.
2024-10-21Refactor (#1877)Dan Davison
2024-09-22Improve blame file type detection (#1829)dvermd
Move blame to CallingProcess Signed-off-by: dvermd <315743+dvermd@users.noreply.github.com>
2024-09-15Do not double panic in FakeParentArgs::dropdvermd
Signed-off-by: dvermd <315743+dvermd@users.noreply.github.com>
2024-09-08Consolidate doc commentsTau Gärtli
2024-09-08Remove fallback to bat theme env varTau Gärtli
The fallback is already handled in `set_options`
2024-09-08Replace "light mode" bool with a dedicated enumTau Gärtli
2024-09-08Make docs proper module-level docsTau Gärtli
2024-09-08Make `use` top-levelTau Gärtli
2024-09-08Merge get_is_light* functions togetherTau Gärtli
2024-09-08Allow --dark to override a light syntax themeTau Gärtli
2024-09-08Add missing test combinationsTau Gärtli
2024-09-08Add test for dark themeTau Gärtli
2024-09-08Do fallback outside switchTau Gärtli
2024-09-08De-duplicate test dataTau Gärtli
2024-09-08Prevent line breaksTau Gärtli
2024-09-06Fix clippy warnings (#1851)Tau Gärtli
* Fix non-portable doc comments warning A line starting with > might be interpreted as a block quote. In regular markdown this could be prevented by escaping the `>` using a backslash. However, since the doc comments are used by clap for the long help more or less verbatim, the `\` would be visible hence the shuffling around of words. * Use `.contains()`
2024-09-02Handle quoted file paths in hunk headersThomas Otto
When core.quotepath is true (the default) then non-ASCII chars in a file name are quoted. These quotes hide the DIFF_PREFIXES and "a/1" "b/1" remains as such, instead of becoming "1" "1". This was interpreted by delta as renamed file. Now these quotes are removed before the DIFF_PREFIXES are searched.
2024-08-24Fix `Catppuccin Latte` name in `LIGHT_SYNTAX_THEMES` list (#1823)Justin Su
2024-08-24Move AmbiguousDiffMinusCounter to hunk_header (#1825)Dan Davison
2024-08-24Don't use a pager for --version (#1824)Dan Davison
2024-08-15Handle ambiguous diff header, '--- ' can also be present in a minus hunkThomas Otto
`diff -u file1 file2` output starts with '--- file1', a '-- 12' line being removed results in '--- 12', which was interpreted as the start of a new diff. Now the number of removed lines announced in the header as e.g. '@@ -1,4 +1,3 @@' is taken into account for this specific diff input.
2024-08-15Support passing arguments to git diff and diff (#1697)Dan Davison
Adds --diff-args with short form -@.
2024-08-12Do not wrap short help (-h) outputThomas Otto
2024-08-01Fix build for rust 1.80Thomas Otto
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-01Use angle bracket around <urls>, regenerate help output markdownThomas Otto
2024-08-01Wrap --help output and use pagerThomas Otto
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-01Add wrap function for --help outputThomas Otto
Unicode and somewhat ANSI aware, can add indentation (skippable) and can also skip wrapping lines by using configurable magic prefixes.
2024-08-01Make drop impl of OutputType more prominentThomas Otto
2024-08-01OutputType: PagerCfg and oneshot_writeThomas Otto
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-07-22Add --max-syntax-highlighting-length, set to 400Thomas Otto
--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-22Add truncate_str_short() which always returns a prefix of the inputThomas Otto
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-21Disable light mode detection in tests (#1765)Tau Gärtli