Skip to content

Commit 1ac9553

Browse files
committed
Don't push empty positions when diffing lines
1 parent 8661279 commit 1ac9553

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

sample_files/compare.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ sample_files/bad_combine_1.rs sample_files/bad_combine_2.rs
2323
f5051bf7d2b8afa3a677388cbd458891 -
2424

2525
sample_files/big_text_hunk_1.txt sample_files/big_text_hunk_2.txt
26-
fd0c8912c094097f82c6b29ae66fb912 -
26+
fc26d41a5ff771670e04033b177973d2 -
2727

2828
sample_files/change_outer_1.el sample_files/change_outer_2.el
2929
2b9334a4cc72da63bba28eff958f0038 -

src/line_parser.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -199,12 +199,14 @@ pub(crate) fn change_positions(lhs_src: &str, rhs_src: &str) -> Vec<MatchedPos>
199199
// individual words.
200200
if lhs_words.len() > MAX_WORDS_IN_LINE || rhs_words.len() > MAX_WORDS_IN_LINE {
201201
for lhs_pos in lhs_lp.from_region(lhs_offset, lhs_offset + lhs_part.len()) {
202-
mps.push(MatchedPos {
203-
kind: MatchKind::NovelWord {
204-
highlight: TokenKind::Atom(AtomKind::Normal),
205-
},
206-
pos: lhs_pos,
207-
});
202+
if lhs_pos.start_col != lhs_pos.end_col {
203+
mps.push(MatchedPos {
204+
kind: MatchKind::NovelWord {
205+
highlight: TokenKind::Atom(AtomKind::Normal),
206+
},
207+
pos: lhs_pos,
208+
});
209+
}
208210
}
209211

210212
lhs_offset += lhs_part.len();

0 commit comments

Comments
 (0)