Fixes for selection

This commit is contained in:
Jeremy Soller 2022-10-21 11:19:24 -06:00
parent 3ed1e938f5
commit da5b69b2bb
No known key found for this signature in database
GPG key ID: 87F211AF2BE4C2FE

View file

@ -673,7 +673,34 @@ impl<'a> TextBuffer<'a> {
}
};
if line_i >= start.line.get() && line_i <= end.line.get() {
// Check if this layout line is inside the selection
let mut inside = false;
if line_i > start.line.get() && line_i < end.line.get() {
// In between start and end lines, definitely inside selection
inside = true;
} else {
if line_i == start.line.get() {
// On edge of start line, check if any contained glyphs are after start
for glyph in layout_line.glyphs.iter() {
if glyph.start >= start.start {
inside = true;
break;
}
}
}
if line_i == end.line.get() && !inside {
// On edge of end line, check if any contained glyphs are before end
for glyph in layout_line.glyphs.iter() {
if glyph.end <= end.end {
inside = true;
break;
}
}
}
}
if inside {
let start_glyph = if start.line.get() == line_i {
cursor_glyph_opt(&start).unwrap_or(0)
} else {