Skip to content

Commit

Permalink
Change the default behavior instead of adding options
Browse files Browse the repository at this point in the history
  • Loading branch information
yoichi committed Mar 5, 2022
1 parent c746724 commit 4ac5035
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 24 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
pager = delta

[interactive]
diffFilter = delta --color-only --caret-encode
diffFilter = delta --color-only

[delta]
navigate = true # use n and N to move between diff sections
Expand Down
7 changes: 0 additions & 7 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,13 +323,6 @@ 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).
///
Expand Down
2 changes: 0 additions & 2 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ pub struct Config {
pub blame_palette: Vec<String>,
pub blame_separator_style: Option<Style>,
pub blame_timestamp_format: String,
pub caret_encode: bool,
pub color_only: bool,
pub commit_regex: Regex,
pub commit_style: Style,
Expand Down Expand Up @@ -269,7 +268,6 @@ impl From<cli::Opt> for Config {
blame_separator_format: parse_blame_line_numbers(&opt.blame_separator_format),
blame_separator_style: styles.remove("blame-separator-style"),
blame_timestamp_format: opt.blame_timestamp_format,
caret_encode: opt.caret_encode,
commit_style: styles["commit-style"],
color_only: opt.color_only,
commit_regex,
Expand Down
1 change: 0 additions & 1 deletion src/options/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ pub fn set_options(
blame_palette,
blame_separator_style,
blame_timestamp_format,
caret_encode,
color_only,
commit_decoration_style,
commit_regex,
Expand Down
23 changes: 11 additions & 12 deletions src/paint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,18 +213,17 @@ impl<'p> Painter<'p> {
painted_prefix(state.clone(), config),
config,
);
if config.caret_encode {
for n in 0..32 {
// HT(0x09), LF(0x0a), ESC(0x1b) are skipped
if n != 0x09 && n != 0x0a && n != 0x1b {
line = line.replace(
&char::from_u32(n).unwrap().to_string(),
&format!(
"\x1b[7m^{}\x1b[27m",
&char::from_u32(n + 64).unwrap().to_string()
),
);
}
// Replace control characters in output with caret notation.
for n in 0..32 {
// HT(0x09), LF(0x0a), ESC(0x1b) are skipped
if n != 0x09 && n != 0x0a && n != 0x1b {
line = line.replace(
&char::from_u32(n).unwrap().to_string(),
&format!(
"\x1b[7m^{}\x1b[27m",
&char::from_u32(n + 64).unwrap().to_string()
),
);
}
}
let (bg_fill_mode, fill_style) =
Expand Down
2 changes: 1 addition & 1 deletion src/tests/test_example_diffs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ commit 94907c0f136f46dc46ffae2dc92dca9af7eb7c2e

#[test]
fn test_carriage_return_is_replaced_with_caret_notation() {
let config = integration_test_utils::make_config_from_args(&["--caret-encode"]);
let config = integration_test_utils::make_config_from_args(&[]);
let output = integration_test_utils::run_delta(
GIT_DIFF_SINGLE_HUNK_WITH_SEQUENCE_OF_CR_ESCAPE_SEQUENCES_LF,
&config,
Expand Down

0 comments on commit 4ac5035

Please sign in to comment.