Fix duplicate visual lines when a word is too long
Words longer than the linewidth used to show up duplicated
This commit is contained in:
parent
e38a302599
commit
8beeca2822
1 changed files with 13 additions and 11 deletions
24
src/shape.rs
24
src/shape.rs
|
|
@ -658,9 +658,8 @@ impl ShapeLine {
|
|||
break;
|
||||
}
|
||||
}
|
||||
word_ranges.push((fitting_start..fitting_end, true));
|
||||
word_ranges.push((fitting_start..fitting_end, true));
|
||||
fitting_end = i + 1;
|
||||
|
||||
fit_x = start_x;
|
||||
}
|
||||
|
||||
|
|
@ -701,15 +700,18 @@ impl ShapeLine {
|
|||
};
|
||||
|
||||
if wrap {
|
||||
word_ranges.push((fitting_start..i, true));
|
||||
|
||||
if word.blank {
|
||||
if fitting_start == i { // One word is bigger than the linewidth
|
||||
i += 1;
|
||||
}
|
||||
word_ranges.push((fitting_start..i, true));
|
||||
if let Some(next_word) = &span.words.get(i) {
|
||||
if next_word.blank {
|
||||
i += 1;
|
||||
}
|
||||
fitting_start = i;
|
||||
|
||||
fit_x = start_x;
|
||||
}
|
||||
fitting_start = i;
|
||||
fit_x = start_x;
|
||||
}
|
||||
|
||||
if self.rtl {
|
||||
fit_x -= word_size;
|
||||
|
|
@ -723,7 +725,9 @@ impl ShapeLine {
|
|||
}
|
||||
}
|
||||
}
|
||||
word_ranges.push((fitting_start..span.words.len(), false));
|
||||
if fitting_start < span.words.len() {
|
||||
word_ranges.push((fitting_start..span.words.len(), false));
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate the actual size
|
||||
|
|
@ -737,7 +741,6 @@ impl ShapeLine {
|
|||
} else {
|
||||
x + word_size > end_x
|
||||
};
|
||||
|
||||
if word_wrap && !wrap_simple {
|
||||
current_visual_line.push((span_index, range.clone()));
|
||||
vl_range_of_spans.push(current_visual_line);
|
||||
|
|
@ -769,7 +772,6 @@ impl ShapeLine {
|
|||
vl_range_of_spans.push(current_visual_line);
|
||||
}
|
||||
|
||||
|
||||
for visual_line in &vl_range_of_spans {
|
||||
let new_order = self.reorder(visual_line);
|
||||
let mut glyphs = Vec::with_capacity(1);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue