From 1ac95534fe9072944ff78757f32efb17f36690d7 Mon Sep 17 00:00:00 2001 From: Wilfred Hughes Date: Tue, 30 Jul 2024 16:15:42 -0700 Subject: [PATCH] Don't push empty positions when diffing lines --- sample_files/compare.expected | 2 +- src/line_parser.rs | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/sample_files/compare.expected b/sample_files/compare.expected index 02ee030209..c9b961d241 100644 --- a/sample_files/compare.expected +++ b/sample_files/compare.expected @@ -23,7 +23,7 @@ sample_files/bad_combine_1.rs sample_files/bad_combine_2.rs f5051bf7d2b8afa3a677388cbd458891 - sample_files/big_text_hunk_1.txt sample_files/big_text_hunk_2.txt -fd0c8912c094097f82c6b29ae66fb912 - +fc26d41a5ff771670e04033b177973d2 - sample_files/change_outer_1.el sample_files/change_outer_2.el 2b9334a4cc72da63bba28eff958f0038 - diff --git a/src/line_parser.rs b/src/line_parser.rs index 14c5c219da..dfea571f2b 100644 --- a/src/line_parser.rs +++ b/src/line_parser.rs @@ -199,12 +199,14 @@ pub(crate) fn change_positions(lhs_src: &str, rhs_src: &str) -> Vec // individual words. if lhs_words.len() > MAX_WORDS_IN_LINE || rhs_words.len() > MAX_WORDS_IN_LINE { for lhs_pos in lhs_lp.from_region(lhs_offset, lhs_offset + lhs_part.len()) { - mps.push(MatchedPos { - kind: MatchKind::NovelWord { - highlight: TokenKind::Atom(AtomKind::Normal), - }, - pos: lhs_pos, - }); + if lhs_pos.start_col != lhs_pos.end_col { + mps.push(MatchedPos { + kind: MatchKind::NovelWord { + highlight: TokenKind::Atom(AtomKind::Normal), + }, + pos: lhs_pos, + }); + } } lhs_offset += lhs_part.len();