Skip to content

Commit

Permalink
Don't push empty positions when diffing lines
Browse files Browse the repository at this point in the history
  • Loading branch information
Wilfred committed Jul 30, 2024
1 parent 8661279 commit 1ac9553
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion sample_files/compare.expected
Original file line number Diff line number Diff line change
Expand Up @@ -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 -
Expand Down
14 changes: 8 additions & 6 deletions src/line_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,14 @@ pub(crate) fn change_positions(lhs_src: &str, rhs_src: &str) -> Vec<MatchedPos>
// 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();
Expand Down

0 comments on commit 1ac9553

Please sign in to comment.