From 90122a6d3cc2174770c96de5b469a6bfe0ec217c Mon Sep 17 00:00:00 2001 From: Wilfred Hughes Date: Thu, 18 Nov 2021 23:02:10 -0800 Subject: [PATCH] Also consider matched lines when calculating which lines to show after After merging hunks, we may have lines on the opposite side. --- src/context.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/context.rs b/src/context.rs index a409fb4ec..26610a198 100644 --- a/src/context.rs +++ b/src/context.rs @@ -216,9 +216,9 @@ pub fn calculate_context( Some(first_line) => match *first_line { (Some(lhs_line), _) => { let mut max_opposite = None; - for (_, rhs_line) in &before_lines { + for (_, rhs_line) in [&before_lines, lines].concat() { if let Some(rhs_line) = rhs_line { - max_opposite = Some(*rhs_line); + max_opposite = Some(rhs_line); } } @@ -232,9 +232,9 @@ pub fn calculate_context( } (_, Some(rhs_line)) => { let mut max_opposite = None; - for (lhs_line, _) in &before_lines { + for (lhs_line, _) in [&before_lines, lines].concat() { if let Some(lhs_line) = lhs_line { - max_opposite = Some(*lhs_line); + max_opposite = Some(lhs_line); } }