aboutsummaryrefslogtreecommitdiff
path: root/src/selection.rs
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2018-03-13 19:00:14 +0100
committerJoe Wilm <joe@jwilm.com>2018-06-02 09:56:50 -0700
commit58c69cafad3b1dafa3631d911c6bfc21f5e5dec5 (patch)
tree73aea66e64622357685600197a9e14c30889f51d /src/selection.rs
parentd9bd21d33f7f35d1362a581cefb1c897a821fcad (diff)
downloadalacritty-58c69cafad3b1dafa3631d911c6bfc21f5e5dec5.tar.gz
alacritty-58c69cafad3b1dafa3631d911c6bfc21f5e5dec5.zip
Fix multi-line selection with single cell end
When the user selected multiple lines, dragging the selection downwards, and then leaves the cursor to the left side of the first cell, the first cell was still incorrectly selected. This has been fixed. The selection also did not update if the mouse was outside of the window, now all movement events are accpeted even when the mouse is outside of the window. This allows updating the selection when the user is dragging the cursor too far. Mouse movement and click events outside of the window are not propagated, these are only used for updating the selection.
Diffstat (limited to 'src/selection.rs')
-rw-r--r--src/selection.rs27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/selection.rs b/src/selection.rs
index 8e7fa29b..d49236a4 100644
--- a/src/selection.rs
+++ b/src/selection.rs
@@ -253,8 +253,31 @@ impl Selection {
// Handle some edge cases
if start.line > end.line {
- start.col += 1;
- end.col -= 1;
+ if end.col > Column(0) {
+ start.col += 1;
+ end.col -= 1;
+ }
+ // Special case for when a multi-line selection to the
+ // bottom ends on a new line with just one cell selected
+ // and the first cell should not be selected
+ else {
+ if start_side == Side::Right {
+ start.col += 1;
+ }
+
+ // Remove the single selected cell if mouse left window
+ if end_side == Side::Left {
+ end.line += 1;
+ end.col = cols - 1;
+ }
+
+ return Some(Span {
+ cols,
+ front: end,
+ tail: start,
+ ty: SpanType::Inclusive,
+ });
+ }
} else if start.line < end.line {
start.col -= 1;
end.col += 1;