summaryrefslogtreecommitdiffstats
path: root/src
AgeCommit message (Collapse)Author
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-11-29Highlighting improvements (#1244)Phillip Wood
* Stop ignoring a passing test edits::tests::test_infer_edits_12 passes so there is no need to ignore it. * Refactor Levenshtein tests Reduce the amount of repetition and specify the Levenshtein distance explicitly in preparation for changing the Levenshtein calculation and adding more tests in a future commit. As there are quite a few inputs to each test use a struct rather than a plain function for the tests as this effectively provides named parameters for the inputs. * Highlight deletions before insertions When a token has moved within a line try to highlight it as a deletion followed by an insertion. Currently -'b ' +' b' is highlighted as -'b[ ]' +'[ ]b' as if the space has moved to the left, instead highlight it as -'[b] ' +' [b]' as if the "b" has moved to the right. As the changes to the tests show this also tends to favor a longer match at the start of the line. * Don't highlight an unchanged trailing space Only unchanged space between changed tokens should be highlighted, if the line ends with an unchanged space then the space should not be highlighted. * Try to group highlighted changes together Sometimes the highlighting of a change is not as clear as it could be. For example the change -printf "%s\n" s y y ... +test_write_lines s y n ... is highlighted as -[printf "%]s[\n"] [s ]y y ... +[test_write_lines ]s y y ... rather than -[printf "%s\n"] s y n ... +[test_write_lines] s y y ... This is because the Levenshtein distance calculation only checks if the current tokens match without considering if the previous tokens matched or not. Adding a small penalty for starting a run of changed tokens forces the changes to be grouped together whenever possible. A knock on effect of adding the penalty is that the cost a substitution needs to be increased relative to the cost of an insertion/deletion otherwise the lowest cost for "ab" -> "ba" is two substitutions rather than an insertion, match and deletion. There are several changes to the tests - the Levenshtein distance is updated to reflect the new calculation in tests::align::* - several new tests are added to tests::align to check the grouping of different combinations of insertions and deletions - tests::edits::test_infer_edits_10 shows an improvement in the highlighting as the unchanged space at the end of the changed tokens is no longer highlighted. This is because it is no longer considered to be deleted by the Levenshtein matching as deleting the space between the deleted words now has a lower cost. - there is a new test in tests::edits using the example in this message. * Stop using substitutions in Levenshtein calculation Now that the lowest cost edit path groups deletions and insertions together there seems to be little point in keeping substitutions. Indeed the lower cost of substitutions compared to a deletion followed by an insertion can adversely affect the highlighting. If the length of the line does not change delta will prefer to use substitutions over deletions and insertions even if it results in unchanged tokens being marked as changed. For example in -[a] a a a a a [b b b] +[c] a a a a a [a c c] unchanged tokens are marked as deleted and inserted. Without substitutions this is highlighted as -a a a a a a [b b b] +[c ]a a a a a a [c c] which highlights the insertion at the beginning of the line and the change at the end of the line more clearly. There is a change to the distance calculation as substitutions only contributed the length of the deletion whereas now the same change will add the length of both the deletion and the insertion. This is addressed by doubling the contribution of unchanged sections so that the denominator equals the sum of the distance contributions of the plus line and minus line.
2022-11-15Handle quoted filenames in diff headerThomas Otto
Otherwise the file extension would return 'rs"' which does not match any language.
2022-11-13Fix clippy warnings (#1236)clnoll
2022-10-24measure_text_width() without constructing a temporary stringThomas Otto
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-10-06Add codeberg link parsing (#1194)Chinmay Dalal
2022-09-15Refactoring ansi/iterator (#1191)Maxim Zhiburt
Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
2022-09-14Add sourcehut link parsing (#1190)Chinmay Dalal
* Add sourcehut link parsing * refactor: GitRemoteRepo::GitHubRepo -> ..::GitHub, repo_slug -> slug https://rust-lang.github.io/rust-clippy/master/index.html#enum_variant_names * readme.md: change bitbucket to sourcehut
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-16Support configurable timestamps in git blame output (#1157)mliszcz
New CLI/config option is introduced: blame-timestamp-output-format. Fixes #1157.
2022-08-07Fix typos (#1151)Kian-Meng Ang
Found via following command: codespell -L crate,nin,numer,struc,ded,fo
2022-07-15Fix git-grep match-highlighting at line-start (#1057)Jackson Popkin
* Fix git-grep match-highlighting at line-start This commit fixes highlighting the part of the line of code that matches the git grep query in cases where the match starts at the beginning of the lines. Fixes #1056. * Fix handling of non-match highlight In some cases, `git grep` will customize the foreground-color for more than just the subset of the line that matches the grep pattern. This breaks the current match-detection behavior, which considers any characters with a non-default "foreground color" within the "code" part of a git-grep-ouput-line to be part of the match. This commit makes match-detection check for boldness and a red foreground instead of just checking for a non-default foreground-color. git grep matches are bold and red by default. But git grep isn't the only reason input to delta may contain color codes; there may still be cases where the highlighting looks wrong here.
2022-07-15Recreate highlighter on each line of `git show $commit:$path` output (#1127)Dan Davison
Prior to this commit, syntax highlighting of scala code was not correct in `git show $commit:$path` output. It was working for other languages as far as I know. I'm not sure why.
2022-07-02Don't attempt to process ANSI sequences in non-UTF8 inputDan Davison
Fixes #677
2022-06-25Fix documentation of DELTA_FEATURESDan Davison
2022-06-22Fix whole-file changes being attributed to the wrong commit in "git log" outputBjörn Steinbrink
The pending buffer for whole-file changes is currently only flushed when encountering a new diff header. This leads to it being carried over across commit boundaries in cases where multiple commits are shown. To fix this, we simply need to flush the buffered data on a commit boundary as well. Fixes #1089
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-06-22Avoid lockup when running without arguments and stdin is connected to tty ↵Björn Steinbrink
(#1112) Up until commit 55287a8 "Run in diff mode iff two positional arguments are supplied" diff mode was only supported when stdin is connected to a tty, which meant that, for example, running `delta a b` in a git hook would do the wrong thing. As a fix, the tty check was removed, so now `delta a b` always works, but the only error condition is now to pass only a single file. When passing no files at all, we try parse to stdin even when connected to a tty. Usually that wouldn't be that bad, because the user could press Ctrl-C or Ctrl-D (EOF) to quit, unfortunately something in the pager setup breaks this, and the only way to exit `delta` is to kill it. Running `delta` with stdin connected to a tty would mean that the user has to manually enter a diff (or paste it), which is not really an expected scenario, as demonstrated by the error message that's currently only emitted when running `delta` with only a single file argument. So we can avoid the lockup by also emitting the error message when running on a tty and there are no files to be diffed. Fixes #1039, fixes #1090
2022-06-20Fix commit hyperlink formatting (#1110)Dan Davison
2022-06-15Only trigger `git show` handler if a file extension was parsed (#1106)Dan Davison
Fixes #1105
2022-05-23Tweak some words improved representation (#1078)Yudai Takada
* Use "overridden" instead of "overriden" * Use "line_numbers" instead of "linennumbers" * Use "context" instead of "contexct" * Use "summary" instead of "sumary"
2022-05-13Update bat, git2, and syntectDan Davison
2022-04-04Apply hyperlinks to diff stat file paths (#1035)Dan Davison
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-30Add support for irreversible-deleteWilliam Escande
Fix #128 Add support for `git diff -D` (aka irreversible delete) The patch is adding a title for removed file, even when there is no file content in the diff output Without the patch, there was no output related to the file at all
2022-03-21Fix typo in --help textDan Davison
2022-03-16Apply file-transformation to diff header, in addition to hunk headerDan Davison
Fixes #1010
2022-03-14Tweak wrap-max-lines documentationDan Davison
2022-03-14Move wrapping logic and utilities into wrapping moduleDan Davison
2022-03-07Flush minus/plus line buffers in additional code locationsDan Davison
Fixes #1002
2022-03-07Add failing test for #1002Dan Davison
2022-03-01Run in diff mode iff two positional arguments are suppliedDan Davison
Fixes #989
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-27ClippyDan Davison
2022-02-23Fall back to plain diff when process substitution is used (#978)Thomas Otto
When detecting input generated by `delta <(echo foo) <(echo bar)` fall back to plain `diff` instead of `git diff --no-index`. This does not respect various git settings anymore (the original reason to switch from `diff` to `git diff`), but is better than just showing the names of the temporary files.
2022-02-21Enable commit links for GitLab (#972)Johan Wärlander
* Enable commit links for GitLab
2022-02-20Support CSI sequences other than SGR (#976)Yoichi NAKAYAMA
* Define Element::Csi_ for non-SGR sequences * Rename (Csi, Csi_) -> (Sgr, Csi)
2022-02-19Fix parsing for .properties files with `-` in path (#975)Jackson Popkin
Fixes #974.
2022-02-15Clarify language: "in front of" → "before" (#967)Waldir Pimenta
2022-02-15Make git include colors in output going to delta (#966)Dan Davison
Fixes #965
2022-02-14Fix hyperlink absolute paths (#939)0.12.0Dan 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-02-07Fix unused imports and functions warnings on windowsThomas Otto
Otherwise these warnings clutter the github diff display.
2022-01-25Use sysinfo::Pid as less as possibleGuillaume Gomez
2022-01-25Fix clippy lintsGuillaume Gomez
2022-01-25Update sysinfo version to 0.23Guillaume Gomez
2022-01-21Show blame line numbers via blame-separator-formatThomas Otto
Prefix and suffix of the format string are separator-style highlighted, format options are none, {n}, {n:block}, {n:every-N}.