summaryrefslogtreecommitdiff
path: root/src/utils
AgeCommit message (Collapse)Author
2025-07-15Fix clippy errors (#2016)Justin Su
2025-01-09clippy 1.84 fixThomas Otto
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-15Rename poorly-named variables (#1904)Dan Davison
2024-11-14Honor pager path when checking less version (#1903)Dan Davison
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-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-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-08-15Support passing arguments to git diff and diff (#1697)Dan Davison
Adds --diff-args with short form -@.
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-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-17Make less version >= 633 behave like previous versions wrt. Nerd FontsThomas Otto
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-09Make relativize_path_maybe directly update the path argumentThomas Otto
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-05-04clippy (#1686)Dan Davison
2024-05-04Repair --default-language, and highlight using full filename (#1549)Thomas Otto
* 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-02-19Accept clippy suggestions (#1632)Dan Davison
2023-07-29Fix issue where pager would be set to `more` or `most` (#1494)ippsav
fix pager env in case of `more/most`
2023-05-31Misc tab refactoring (#1424)Thomas Otto
* Move tabs logic into utils * Re-use buffer returned by tabs::expand * Add TabCfg to configure tabs Use the String from this config for the tab replacement. This avoids creating a new String for each processed line. * Avoid unicode segmentation for each line just to remove a prefix In some code paths no prefix is removed, and in almost all other cases the prefix is just ascii. This simplifies a lot of calls. * Set default tab with to 8 Editors like vim, emacs, nano and most terminal emulators set this value as the default tab display width.
2023-04-26Replace deprecated `error_chain` crate with `anyhow` (#1405)nickelc
The `error_chain` crate is now deprecated for a long time and `anyhow` has proven to be a popular replacement for applications. This also improves the current error messages for panics. ``` PAGER='"less' git show thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: \ Error(Msg("Could not parse pager command."), State { next_error: Some(ParseError), \ backtrace: InternalBacktrace })', src/main.rs:136:88 ``` ``` PAGER='"less' git show thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Could not parse pager command. Caused by: missing closing quote', src/main.rs:125:88 ```
2023-03-10Derive the default for enums with `#[derive(Default)]`/`#[default]` (#1341)nickelc
2023-03-05Update dependencies & switch back to the `dirs` crate (#1325)nickelc
* Update direct dependencies * Update transient dependencies * Switch back to `dirs` crate The `dirs`/`dirs-sys` repositories are unarchived and the crates are maintained again, while `dirs-next` crates aren't.
2023-03-03Spelling (#1257)Josh Soref
Corrects misspellings identified by https://github.com/marketplace/actions/check-spelling Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
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-11-13Fix clippy warnings (#1236)clnoll
2022-10-11Add terminal width fallback via stty if on Windows/MSYS2Thomas Otto
Also new workarounds.rs file, and DELTA_NO_WORKAROUNDS env var to disable these.
2022-10-11Fix clippy warnings after rust 1.64 upgradeThomas Otto
2022-08-16Fix clippy warnings after rust 1.63 upgrademliszcz
Following fixes are included: * derive_partial_eq_without_eq: Eq trait was added by running `cargo clippy --fix --no-deps`. * get_first: Function was replaced by running `cargo clippy --fix --no-deps`. * unnecessary_to_owned: This check was disabled for ANSIString as to_string call is required to enforce formatting. Otherwise the underlying string was returned directly (probably due to Deref implementation). * type_complexity: Closure type was simplified and Box<> usage was removed.
2022-08-07Fix typos (#1151)Kian-Meng Ang
Found via following command: codespell -L crate,nin,numer,struc,ded,fo
2022-07-02Don't attempt to process ANSI sequences in non-UTF8 inputDan Davison
Fixes #677
2022-06-22Allow to run tests using "cargo t"Björn Steinbrink
The test_process_calling_cmdline test only allows "cargo test" and "cargo tarpaulin" for running the testsuite, for "cargo t" is a built-in alias for "cargo test" and should be allowed, too.
2022-03-30Add custom env struct to store env at init (#1025)William Escande
This allow to no longer ignore some tests (marked previously as FIXME) by storing the env at the start of the program (Or creating a custom env for test purpose) This centralize almost alls calls to std::env inside one wrapper Add a test profile to increase speed for testing (5min -> 20sec on my machine) clean a few code style like this: ``` if Some(value) = ... if value ``` to ``` if Some(true) = ... ``` Co-authored-by: William Escande <wescande@google.com>
2022-03-01Disable full process scans on LinuxThomas Otto
The env var DELTA_CALLING_PROCESS_QUERY_ALL re-enables this last resort method. However usually this is just an expensive scan which doesn't find the caller anyhow.
2022-03-01Also look at grandparent process when determining the callerThomas Otto
2022-02-27Use assets API from bat library instead of vendored code (#903)Dan Davison
Use assets API from bat library Fixes #895 Ref https://github.com/sharkdp/bat/issues/2026 Thanks @Enselic
2022-02-14Fix hyperlink absolute paths (#939)Dan Davison
Fix file paths and hyperlinks With this commit the target of a hyperlink should always be an absolute path. This should be true for all file hyperlinks, e.g. - File hyperlink - Hunk header hyperlink - Line number hyperlink Fixes #890
2022-01-25Use sysinfo::Pid as less as possibleGuillaume Gomez
2022-01-25Update sysinfo version to 0.23Guillaume Gomez
2022-01-18Cwd fixups (#918)Dan Davison
Do cwd computations once only; rename cwd variable
2022-01-17Construct hyperlink file path relative to cwdDan Davison
Fixes #890
2022-01-13Fix new 1.58 clippy lintsThomas Otto
2022-01-06New option file-transformation to transform file pathsDan Davison
2022-01-03Cache parent process when testing unless FakeParentArgs are usedThomas Otto
2022-01-03The calling process must have a common parent with deltaThomas Otto
Ensures that no unrelated process is found when selectively refreshing a pid range.
2022-01-03Move parent process query into a threadThomas Otto
Start the query even before determining if information about the parent process is required (which are most invocations anyhow).
2022-01-03Re-enable full process scans on LinuxThomas Otto
2022-01-03Disable /proc fd caching on Linux when querying processesThomas Otto
This query only happens once, so caching is not needed Also update sysinfo version to fix a crash related to this.
2021-12-11Do not query CPU data when querying process data (#845)Dan Davison
* Do not query CPU data when querying process data Fixes #839 Ref https://github.com/GuillaumeGomez/sysinfo/issues/632 * Update branch of sysinfo * Update upstream sysinfo commit Ref https://github.com/GuillaumeGomez/sysinfo/pull/636 * Point sysinfo at an explicit commit rather than a symbolic branch name commit d647acfbf216848a8237e1f9251b2c48860a547f Merge: 989ac6c 67a586c Author: Guillaume Gomez <guillaume1.gomez@gmail.com> Date: 2 hours ago Merge pull request #636 from GuillaumeGomez/update-if-needed Only update processors if needed