summaryrefslogtreecommitdiffstats
path: root/src/features/line_numbers.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/features/line_numbers.rs')
-rw-r--r--src/features/line_numbers.rs24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/features/line_numbers.rs b/src/features/line_numbers.rs
index 3afce6b1..0cc4ebfb 100644
--- a/src/features/line_numbers.rs
+++ b/src/features/line_numbers.rs
@@ -6,7 +6,7 @@ use regex::Regex;
use crate::config;
use crate::delta::State;
use crate::features::hyperlinks;
-use crate::features::side_by_side::ansifill;
+use crate::features::side_by_side::ansifill::{self, ODD_PAD_CHAR};
use crate::features::side_by_side::{Left, PanelSide, Right};
use crate::features::OptionValueFunction;
use crate::format::{self, Align, Placeholder};
@@ -175,9 +175,7 @@ impl<'a> LineNumbersData<'a> {
insert_center_space_on_odd_width,
),
),
- line_number: MinusPlus::new(0, 0),
- hunk_max_line_number_width: 0,
- plus_file: "".to_string(),
+ ..Self::default()
}
}
@@ -193,6 +191,24 @@ impl<'a> LineNumbersData<'a> {
self.plus_file = plus_file;
}
+ pub fn empty_for_sbs(use_full_width: ansifill::UseFullPanelWidth) -> LineNumbersData<'a> {
+ let insert_center_space_on_odd_width = use_full_width.pad_width();
+ Self {
+ format_data: if insert_center_space_on_odd_width {
+ let format_left = vec![format::FormatStringPlaceholderData::default()];
+ let format_right = vec![format::FormatStringPlaceholderData {
+ prefix: format!("{}", ODD_PAD_CHAR).into(),
+ prefix_len: 1,
+ ..Default::default()
+ }];
+ MinusPlus::new(format_left, format_right)
+ } else {
+ MinusPlus::default()
+ },
+ ..Self::default()
+ }
+ }
+
pub fn formatted_width(&self) -> SideBySideLineWidth {
let format_data_width = |format_data: &format::FormatStringData<'a>| {
// Provide each Placeholder with the max_line_number_width to calculate the