diff options
author | Christian Duerr <contact@christianduerr.com> | 2018-03-10 12:14:58 +0100 |
---|---|---|
committer | Joe Wilm <joe@jwilm.com> | 2018-06-02 09:46:20 -0700 |
commit | d9bd21d33f7f35d1362a581cefb1c897a821fcad (patch) | |
tree | 945089b96fbbad1b153430d1565a410003be30f5 /src/selection.rs | |
parent | a238e9ac5832cb9a40f886a3b873728cd7890d01 (diff) | |
download | alacritty-d9bd21d33f7f35d1362a581cefb1c897a821fcad.tar.gz alacritty-d9bd21d33f7f35d1362a581cefb1c897a821fcad.zip |
Fix selection in scrollback
There were a few issues with selection in scrollback that were mainly
off-by-one errors. This aims at fixing these issues.
This also fixes a bug that currently exists in master where the last
cell is not selected when the mouse leaves the window to the right.
Diffstat (limited to 'src/selection.rs')
-rw-r--r-- | src/selection.rs | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/selection.rs b/src/selection.rs index 31787bbb..8e7fa29b 100644 --- a/src/selection.rs +++ b/src/selection.rs @@ -191,8 +191,6 @@ impl Selection { (region.end, region.start) }; - println!("BEFORE front={:?}, start={:?}, tail={:?}, end={:?}", front, start, tail, end); - if front < tail && front.line == tail.line { start = grid.semantic_search_left(front); end = grid.semantic_search_right(tail); @@ -201,8 +199,6 @@ impl Selection { end = grid.semantic_search_left(tail); } - println!("AFTER front={:?}, start={:?}, tail={:?}, end={:?}", front, start, tail, end); - if start > end { ::std::mem::swap(&mut start, &mut end); } @@ -249,12 +245,21 @@ impl Selection { } fn span_simple<G: Dimensions>(grid: &G, region: &Range<Anchor>) -> Option<Span> { - let start = region.start.point; + let mut start = region.start.point; let start_side = region.start.side; - let end = region.end.point; + let mut end = region.end.point; let end_side = region.end.side; let cols = grid.dimensions().col; + // Handle some edge cases + if start.line > end.line { + start.col += 1; + end.col -= 1; + } else if start.line < end.line { + start.col -= 1; + end.col += 1; + } + let (front, tail, front_side, tail_side) = if start > end { // Selected upward; start/end are swapped (end, start, end_side, start_side) |