From c746724dcf2f67290ca42efbd1a1a96f382f2c48 Mon Sep 17 00:00:00 2001 From: Yoichi Nakayama Date: Thu, 3 Mar 2022 07:16:13 +0900 Subject: [PATCH 1/2] New option caret-encode to avoid the display issue with git add -p --- README.md | 2 +- src/cli.rs | 7 +++++++ src/config.rs | 2 ++ src/delta.rs | 11 ----------- src/options/set.rs | 1 + src/paint.rs | 14 ++++++++++++++ src/tests/test_example_diffs.rs | 5 +++-- 7 files changed, 28 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index c2240e858..cb0ab9977 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ pager = delta [interactive] - diffFilter = delta --color-only + diffFilter = delta --color-only --caret-encode [delta] navigate = true # use n and N to move between diff sections diff --git a/src/cli.rs b/src/cli.rs index 15efd15ee..e340ad087 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -323,6 +323,13 @@ pub struct Opt { /// If a relativized file path exceeds this width then the diff stat will be misaligned. pub diff_stat_align_width: usize, + #[clap(long = "caret-encode")] + /// Replace control characters in output with caret notation. + /// + /// This option is supposed to be used in interactive.diffFilter configuration for `git add -p` + /// where raw control characters result in strange display. + pub caret_encode: bool, + #[clap(long = "features", value_name = "FEATURES")] /// Names of delta features to activate (space-separated). /// diff --git a/src/config.rs b/src/config.rs index e06d84af5..ed00e98ee 100644 --- a/src/config.rs +++ b/src/config.rs @@ -70,6 +70,7 @@ pub struct Config { pub blame_palette: Vec, pub blame_separator_style: Option