From eacd09b167f0603f4d00afdb0889868fc9069bd6 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Fri, 21 Oct 2022 11:27:21 -0600 Subject: [PATCH] Fix selection when start and end lines match --- src/buffer.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/buffer.rs b/src/buffer.rs index 8f94523..8acfc94 100644 --- a/src/buffer.rs +++ b/src/buffer.rs @@ -679,7 +679,15 @@ impl<'a> TextBuffer<'a> { // In between start and end lines, definitely inside selection inside = true; } else { - if line_i == start.line.get() { + if line_i == start.line.get() && line_i == end.line.get() { + // On edge of start and end line, check if any contained glyphs are after start and before end + for glyph in layout_line.glyphs.iter() { + if glyph.start >= start.start && glyph.end <= end.end{ + inside = true; + break; + } + } + } 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 { @@ -687,9 +695,7 @@ impl<'a> TextBuffer<'a> { break; } } - } - - if line_i == end.line.get() && !inside { + } else if line_i == end.line.get() { // 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 {