Skip to content

Commit

Permalink
Disable line numbers and side-by-side under --word-diff
Browse files Browse the repository at this point in the history
We currently have no way of computing correct line numbers: it seems that we would need to identify
wholly added and removed lines from the ANSI color sequences. side-by-side is (I imagine) almost
always used with line numbers, and it doesn't make much sense for word-diff anyway.
  • Loading branch information
dandavison committed Dec 10, 2021
1 parent 83dda78 commit ffb2804
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use crate::fatal;
use crate::features::navigate;
use crate::features::side_by_side::{self, ansifill, LeftRight};
use crate::git_config::{GitConfig, GitConfigEntry};
use crate::handlers;
use crate::minusplus::MinusPlus;
use crate::paint::BgFillMethod;
use crate::parse_styles;
Expand Down Expand Up @@ -291,7 +292,7 @@ impl From<cli::Opt> for Config {
} else {
line_fill_method
},
line_numbers: opt.line_numbers,
line_numbers: opt.line_numbers && !*handlers::hunk::IS_WORD_DIFF,
line_numbers_format: LeftRight::new(
opt.line_numbers_left_format,
opt.line_numbers_right_format,
Expand Down Expand Up @@ -350,7 +351,7 @@ impl From<cli::Opt> for Config {
git_plus_style: styles["git-plus-style"],
relative_paths: opt.relative_paths,
show_themes: opt.show_themes,
side_by_side: opt.side_by_side,
side_by_side: opt.side_by_side && !*handlers::hunk::IS_WORD_DIFF,
side_by_side_data,
styles_map,
syntax_dummy_theme: SyntaxTheme::default(),
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/hunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::utils::process::{self, CallingProcess};
use unicode_segmentation::UnicodeSegmentation;

lazy_static! {
static ref IS_WORD_DIFF: bool = match process::calling_process().as_deref() {
pub static ref IS_WORD_DIFF: bool = match process::calling_process().as_deref() {
Some(
CallingProcess::GitDiff(cmd_line)
| CallingProcess::GitShow(cmd_line, _)
Expand Down

0 comments on commit ffb2804

Please sign in to comment.