Skip to content

Commit

Permalink
Fix right panel background extending beyond the truncation symbol
Browse files Browse the repository at this point in the history
In side-by-side mode, if `background_color_extends_to_terminal_width`
is set, the left panel color is extended via spaces, but the right
one via an ANSI sequence which instructs the terminal emulator to
fill the background color rightwards.

However due to the padding after the right panel the color will
extend beyond a possible truncation symbol:

"TEXT#AB→#", not "TEXT#AB→ " with "#" being the green background.

If any line is truncated, the entire block is now padded with spaces
(if only selected lines used spaces the line would show a jagged
right edge)

Add enums `BgFillWidth` and `BgFillMethod` to better distinguish
if the background should be filled, and if so how (ANSI or Spaces).
  • Loading branch information
th1000s committed Feb 14, 2021
1 parent ef242c5 commit 306621b
Show file tree
Hide file tree
Showing 5 changed files with 232 additions and 159 deletions.
10 changes: 5 additions & 5 deletions src/features/line_numbers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ pub mod tests {
let mut lines = output.lines().skip(7);
let (line_1, line_2) = (lines.next().unwrap(), lines.next().unwrap());
assert_eq!(strip_ansi_codes(line_1), " 1 ⋮ │a = 1");
assert_eq!(strip_ansi_codes(line_2), " 2 ⋮ │b = 2");
assert_eq!(strip_ansi_codes(line_2), " 2 ⋮ │b = 23456");
}

#[test]
Expand All @@ -606,7 +606,7 @@ pub mod tests {
let mut lines = output.lines().skip(7);
let (line_1, line_2) = (lines.next().unwrap(), lines.next().unwrap());
assert_eq!(strip_ansi_codes(line_1), " ⋮ 1 │a = 1");
assert_eq!(strip_ansi_codes(line_2), " ⋮ 2 │b = 2");
assert_eq!(strip_ansi_codes(line_2), " ⋮ 2 │b = 234567");
}

#[test]
Expand Down Expand Up @@ -688,7 +688,7 @@ pub mod tests {
let mut lines = output.lines().skip(5);
let (line_1, line_2) = (lines.next().unwrap(), lines.next().unwrap());
assert_eq!(strip_ansi_codes(line_1), " 1 ⋮ │-a = 1");
assert_eq!(strip_ansi_codes(line_2), " 2 ⋮ │-b = 2");
assert_eq!(strip_ansi_codes(line_2), " 2 ⋮ │-b = 23456");
}

#[test]
Expand All @@ -713,7 +713,7 @@ index 223ca50..e69de29 100644
+++ w/a.py
@@ -1,2 +0,0 @@
-a = 1
-b = 2
-b = 23456
";

pub const TWO_PLUS_LINES_DIFF: &str = "\
Expand All @@ -724,7 +724,7 @@ index 0000000..223ca50
+++ i/a.py
@@ -0,0 +1,2 @@
+a = 1
+b = 2
+b = 234567
";

pub const ONE_MINUS_ONE_PLUS_LINE_DIFF: &str = "\
Expand Down

0 comments on commit 306621b

Please sign in to comment.