Commit Graph

60 Commits

Author SHA1 Message Date
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
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
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
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
Dan Davison
d995bf76cf clippy (#1686) 2024-05-04 10:00:44 -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
Dan Davison
084a6d19b2 Accept clippy suggestions (#1632) 2024-02-19 12:56:22 -05:00
ippsav
3c55764215 Fix issue where pager would be set to more or most (#1494)
fix pager env in case of `more/most`
2023-07-29 19:25:02 -04:00
Thomas Otto
139cdb9656 Misc tab refactoring (#1424)
* 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-05-31 13:17:18 -04:00
nickelc
ce41a39bf6 Replace deprecated error_chain crate with anyhow (#1405)
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-04-26 15:07:35 -04:00
nickelc
164213501d Derive the default for enums with #[derive(Default)]/#[default] (#1341) 2023-03-10 08:13:20 -05:00
nickelc
a8446c53bb Update dependencies & switch back to the dirs crate (#1325)
* 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-05 15:07:25 -05:00
Josh Soref
590d5fa2eb Spelling (#1257)
Corrects misspellings identified by https://github.com/marketplace/actions/check-spelling

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-03-03 05:31:28 -05:00
nickelc
28bf556897 Fix clippy warnings (#1298)
* 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`
2023-02-28 06:37:20 -05:00
clnoll
6b2d0b7fc8 Fix clippy warnings (#1236) 2022-11-13 18:54:39 -05:00
Thomas Otto
60492f318f Add terminal width fallback via stty if on Windows/MSYS2
Also new workarounds.rs file, and DELTA_NO_WORKAROUNDS env var
to disable these.
2022-10-11 16:19:25 -04:00
Thomas Otto
65044c0e0d Fix clippy warnings after rust 1.64 upgrade 2022-10-11 16:19:25 -04:00
mliszcz
b99e6c5d9c Fix clippy warnings after rust 1.63 upgrade
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-16 18:17:10 -04:00
Kian-Meng Ang
738c5a141b Fix typos (#1151)
Found via following command:

    codespell -L crate,nin,numer,struc,ded,fo
2022-08-07 10:42:36 -04:00
Dan Davison
ab8015e4f7 Don't attempt to process ANSI sequences in non-UTF8 input
Fixes #677
2022-07-02 17:07:29 -04:00
Björn Steinbrink
e28e97de7a Allow to run tests using "cargo t"
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-06-22 08:49:42 -04:00
William Escande
85a07cd109 Add custom env struct to store env at init (#1025)
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-30 20:35:10 -04:00
Thomas Otto
d13c41c3fe Disable full process scans on Linux
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-01 18:58:55 -05:00
Thomas Otto
d2f5a9077c Also look at grandparent process when determining the caller 2022-03-01 18:58:55 -05:00
Dan Davison
1403fe2b8e Use assets API from bat library instead of vendored code (#903)
Use assets API from bat library

Fixes #895
Ref https://github.com/sharkdp/bat/issues/2026
Thanks @Enselic
2022-02-27 12:08:23 -05:00
Dan Davison
3d5b6852a0 Fix hyperlink absolute paths (#939)
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-02-14 12:30:30 -05:00
Guillaume Gomez
9436b05418 Use sysinfo::Pid as less as possible 2022-01-25 09:12:04 -05:00
Guillaume Gomez
019752a664 Update sysinfo version to 0.23 2022-01-25 09:12:04 -05:00
Dan Davison
7d8533c984 Cwd fixups (#918)
Do cwd computations once only; rename cwd variable
2022-01-18 09:02:21 -05:00
Dan Davison
e9e9fb7c69 Construct hyperlink file path relative to cwd
Fixes #890
2022-01-17 18:30:32 -05:00
Thomas Otto
c323fa529b Fix new 1.58 clippy lints 2022-01-13 19:53:28 -05:00
Dan Davison
95eb0a0e58 New option file-transformation to transform file paths 2022-01-06 12:20:17 -05:00
Thomas Otto
59604a376f Cache parent process when testing unless FakeParentArgs are used 2022-01-03 17:28:27 -05:00
Thomas Otto
c1392d6e1c The calling process must have a common parent with delta
Ensures that no unrelated process is found when selectively
refreshing a pid range.
2022-01-03 17:28:27 -05:00
Thomas Otto
3a3f597704 Move parent process query into a thread
Start the query even before determining if information about the
parent process is required (which are most invocations anyhow).
2022-01-03 17:28:27 -05:00
Thomas Otto
15d7bb8cf0 Re-enable full process scans on Linux 2022-01-03 17:28:27 -05:00
Thomas Otto
8f2a8ce496 Disable /proc fd caching on Linux when querying processes
This query only happens once, so caching is not needed

Also update sysinfo version to fix a crash related to this.
2022-01-03 17:28:27 -05:00
Dan Davison
69c7aaa28f Do not query CPU data when querying process data (#845)
* 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
2021-12-11 15:31:34 -05:00
Thomas Otto
5c1612ec0a Query fewer processes when searching for the parent
This query now happens for more invocation types, so speed it up.
Call `refresh_process()` only on pids numerically close to the one
of delta itself.
2021-12-11 15:14:41 -05:00
Dan Davison
0b3aefb48c Disable last-resort process tree inspection
See #824 in which some users are reporting very slow performance.

Fixes #824
2021-12-07 21:40:42 -05:00
Thomas Otto
e5eea75eee Fixed some test clippys
Note that currently `cargo clippy --tests` is not checked by the CI runs
2021-12-07 19:18:23 -05:00
Dan Davison
1f444c9d36 Silence warning 2021-12-04 22:29:31 -05:00
Thomas Otto
b38c0f0bba Fix new v1.57 clippy warnings 2021-12-02 20:33:35 -05:00
Dan Davison
b0e02830b2 Do not handle --word-diff or --color-words output
Fixes #440
Ref #152
2021-11-29 08:41:24 -05:00
Dan Davison
67df50c8a8 Refactor: parse command line 2021-11-29 08:41:24 -05:00
Thomas Otto
1c9be71dd9 Test sibling process detection 2021-11-29 08:39:56 -05:00
Thomas Otto
46b0c0441a Match process binary case insensitively 2021-11-29 08:39:56 -05:00
Thomas Otto
b34a031122 Clean up FakeParentArgs
Can fake once, for_scope, or with a given list.
2021-11-29 08:39:56 -05:00