summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Davison <dandavison7@gmail.com>2020-12-27 21:34:56 +0000
committerDan Davison <dandavison7@gmail.com>2020-12-27 21:51:28 +0000
commit32e068bf6e736ff9d364b9d066adbfc62e69b944 (patch)
tree2e03344fe1b23d917ee56ad4ea0be590cb072d3f
parent4bb7343383d84a10cc14dcb2cb90f91f29290ff6 (diff)
Revert "Interpret `line-numbers = false` in gitconfig as no line numbers at all (#296)"
-rw-r--r--src/cli.rs14
-rw-r--r--src/config.rs5
-rw-r--r--src/hunk_header.rs6
-rw-r--r--src/options/option_value.rs7
-rw-r--r--src/options/set.rs29
5 files changed, 3 insertions, 58 deletions
diff --git a/src/cli.rs b/src/cli.rs
index 22e3de2b..8fa38c69 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -578,7 +578,6 @@ pub struct ComputedValues {
pub decorations_width: Width,
pub inspect_raw_lines: InspectRawLines,
pub is_light_mode: bool,
- pub line_numbers_mode: LineNumbersMode,
pub paging_mode: PagingMode,
pub syntax_dummy_theme: SyntaxTheme,
pub syntax_set: SyntaxSet,
@@ -610,19 +609,6 @@ impl Default for InspectRawLines {
}
}
-#[derive(Clone, Debug, PartialEq)]
-pub enum LineNumbersMode {
- None,
- First,
- Full,
-}
-
-impl Default for LineNumbersMode {
- fn default() -> Self {
- LineNumbersMode::First
- }
-}
-
impl Default for PagingMode {
fn default() -> Self {
PagingMode::Never
diff --git a/src/config.rs b/src/config.rs
index 6d47ac59..d7f99b20 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -44,7 +44,6 @@ pub struct Config {
pub line_numbers_plus_style: Style,
pub line_numbers_right_format: String,
pub line_numbers_right_style: Style,
- pub line_numbers_show_first_line_number: bool,
pub line_numbers_zero_style: Style,
pub line_buffer_size: usize,
pub max_line_distance: f64,
@@ -172,15 +171,13 @@ impl From<cli::Opt> for Config {
hyperlinks_file_link_format: opt.hyperlinks_file_link_format,
inspect_raw_lines: opt.computed.inspect_raw_lines,
keep_plus_minus_markers: opt.keep_plus_minus_markers,
- line_numbers: (opt.computed.line_numbers_mode == cli::LineNumbersMode::Full),
+ line_numbers: opt.line_numbers,
line_numbers_left_format: opt.line_numbers_left_format,
line_numbers_left_style,
line_numbers_minus_style,
line_numbers_plus_style,
line_numbers_right_format: opt.line_numbers_right_format,
line_numbers_right_style,
- line_numbers_show_first_line_number: (opt.computed.line_numbers_mode
- == cli::LineNumbersMode::First),
line_numbers_zero_style,
line_buffer_size: opt.line_buffer_size,
max_line_distance: opt.max_line_distance,
diff --git a/src/hunk_header.rs b/src/hunk_header.rs
index b335b097..d5fbef48 100644
--- a/src/hunk_header.rs
+++ b/src/hunk_header.rs
@@ -96,11 +96,7 @@ fn _write_hunk_header(
);
have_hunk_header = true;
};
- if !config.line_numbers
- && config.line_numbers_show_first_line_number
- && !config.hunk_header_style.is_raw
- && !config.color_only
- {
+ if !config.line_numbers && !config.hunk_header_style.is_raw && !config.color_only {
if have_hunk_header {
let _ = write!(&mut painter.output_buffer, ":");
}
diff --git a/src/options/option_value.rs b/src/options/option_value.rs
index d569f676..cbe5b383 100644
--- a/src/options/option_value.rs
+++ b/src/options/option_value.rs
@@ -55,13 +55,6 @@ impl From<OptionValue> for Option<String> {
fn from(value: OptionValue) -> Self {
match value {
OptionValue::OptionString(value) => value,
- // HACK: See the comment in options::set::compute_line_numbers_mode(). That function
- // deliberately reads what is normally a boolean value ('line-numbers') as a string.
- // However options::get::get_option_value() can fall through to obtaining the value
- // from builtin_features, in which case an OptionValue::Boolean will be encountered.
- // See the comment in options::set::compute_line_numbers_mode() and docstring of
- // options::get::get_option_value().
- OptionValue::Boolean(_) => None,
_ => delta_unreachable("Error converting OptionValue to Option<String>."),
}
}
diff --git a/src/options/set.rs b/src/options/set.rs
index 5b68ffec..cebdd2f7 100644
--- a/src/options/set.rs
+++ b/src/options/set.rs
@@ -16,7 +16,7 @@ use crate::features;
use crate::git_config;
use crate::git_config_entry::{self, GitConfigEntry};
use crate::options::option_value::{OptionValue, ProvenancedOptionValue};
-use crate::options::{self, theme};
+use crate::options::theme;
macro_rules! set_options {
([$( $field_ident:ident ),* ],
@@ -186,8 +186,6 @@ pub fn set_options(
opt.computed.inspect_raw_lines =
cli::InspectRawLines::from_str(&opt.inspect_raw_lines).unwrap();
- opt.computed.line_numbers_mode =
- compute_line_numbers_mode(opt, &builtin_features, git_config, &option_names);
opt.computed.paging_mode = parse_paging_mode(&opt.paging_mode);
// --color-only is used for interactive.diffFilter (git add -p). side-by-side, and
@@ -201,31 +199,6 @@ pub fn set_options(
}
}
-fn compute_line_numbers_mode(
- opt: &cli::Opt,
- builtin_features: &HashMap<String, features::BuiltinFeature>,
- git_config: &mut Option<git_config::GitConfig>,
- option_names: &HashMap<&str, &str>,
-) -> cli::LineNumbersMode {
- // line-numbers is in general treated as a boolean value. We read it as a string here in order
- // to interpret an explicit "false" (as opposed to merely absence) as meaning "Do not show any
- // line numbers; not even the first line number of the hunk".
- let line_numbers_string_value: Option<Option<String>> = options::get::get_option_value(
- option_names["line-numbers"],
- builtin_features,
- opt,
- git_config,
- );
- match (
- line_numbers_string_value.as_ref().map(|val| val.as_deref()),
- opt.line_numbers,
- ) {
- (Some(Some("false")), _) => cli::LineNumbersMode::None,
- (_, true) => cli::LineNumbersMode::Full,
- (_, false) => cli::LineNumbersMode::First,
- }
-}
-
#[allow(non_snake_case)]
fn set__light__dark__syntax_theme__options(
opt: &mut cli::Opt,