summaryrefslogtreecommitdiffstats
path: root/src/features
diff options
context:
space:
mode:
Diffstat (limited to 'src/features')
-rw-r--r--src/features/line_numbers.rs24
-rw-r--r--src/features/side_by_side.rs4
2 files changed, 22 insertions, 6 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
diff --git a/src/features/side_by_side.rs b/src/features/side_by_side.rs
index b052f97c..ddc7f55d 100644
--- a/src/features/side_by_side.rs
+++ b/src/features/side_by_side.rs
@@ -465,8 +465,8 @@ pub mod ansifill {
/// The solution in this case is to add `ODD_PAD_CHAR` before the first line number in
/// the right panel and increasing its width by one, thus using the full terminal width
/// with the two panels.
- /// This also means line numbers can not be disabled in side-by-side mode plus ANSI, as
- /// this leaves no place for this fix.
+ /// This also means line numbers can not be disabled in side-by-side mode, but they may
+ /// not actually paint numbers.
#[derive(Clone, Debug)]
pub struct UseFullPanelWidth(pub bool);
impl UseFullPanelWidth {