aboutsummaryrefslogtreecommitdiff
path: root/src/selection.rs
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2018-03-13 22:48:08 +0100
committerJoe Wilm <joe@jwilm.com>2018-06-02 09:56:50 -0700
commite20aa550cbcf7b3f7be6757c007960b3f9b1ac08 (patch)
tree59acb455a5aedc6b88f4eb5aa5422057d745dfa8 /src/selection.rs
parentb0f272f41950558cfec36414d2430d524d7b8b55 (diff)
downloadalacritty-e20aa550cbcf7b3f7be6757c007960b3f9b1ac08.tar.gz
alacritty-e20aa550cbcf7b3f7be6757c007960b3f9b1ac08.zip
Fix selection starting in first cell
When selecting to the top and starting in the first cell, alacritty would crash. These cases have been fixed and now selection should be completely working.
Diffstat (limited to 'src/selection.rs')
-rw-r--r--src/selection.rs25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/selection.rs b/src/selection.rs
index d49236a4..f775f1f6 100644
--- a/src/selection.rs
+++ b/src/selection.rs
@@ -279,8 +279,31 @@ impl Selection {
});
}
} else if start.line < end.line {
- start.col -= 1;
end.col += 1;
+ if start.col > Column(0) {
+ start.col -= 1;
+ }
+ // Special case for when a selection is started
+ // in the first cell of a line
+ else {
+ let ty = match end_side {
+ Side::Left => SpanType::ExcludeTail,
+ Side::Right => SpanType::Inclusive,
+ };
+
+ // Switch start cell to last cell of previous line
+ if start_side == Side::Left {
+ start.line += 1;
+ start.col = cols - 1;
+ }
+
+ return Some(Span {
+ ty,
+ cols,
+ front: start,
+ tail: end,
+ });
+ }
}
let (front, tail, front_side, tail_side) = if start > end {