aboutsummaryrefslogtreecommitdiff
path: root/alacritty_terminal/src/selection.rs
diff options
context:
space:
mode:
authorJean Mertz <jean@mertz.fm>2019-05-11 18:15:32 +0200
committerChristian Duerr <chrisduerr@users.noreply.github.com>2019-05-11 16:15:32 +0000
commit1656aff85ed7412fd6ab8a7f75384f86d98a483b (patch)
tree6c8f2202ef8ce19f6098dee2e3087bf4dc8cb8a3 /alacritty_terminal/src/selection.rs
parentca9724a5efe38a2db47d1b44b9d9f75cb6b6d20e (diff)
downloadalacritty-1656aff85ed7412fd6ab8a7f75384f86d98a483b.tar.gz
alacritty-1656aff85ed7412fd6ab8a7f75384f86d98a483b.zip
Add support for double-click bracket-pair selection
Diffstat (limited to 'alacritty_terminal/src/selection.rs')
-rw-r--r--alacritty_terminal/src/selection.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/alacritty_terminal/src/selection.rs b/alacritty_terminal/src/selection.rs
index 6aaedf2d..ad2f2ba9 100644
--- a/alacritty_terminal/src/selection.rs
+++ b/alacritty_terminal/src/selection.rs
@@ -188,14 +188,20 @@ impl Selection {
Selection::alt_screen_clamp(&mut start, &mut end, lines, cols)?;
}
- let (mut start, mut end) = if start < end && start.line == end.line {
+ let (mut start, mut end) = if start == end {
+ if let Some(end) = grid.bracket_search(start.into()) {
+ (start.into(), end)
+ } else {
+ (grid.semantic_search_right(start.into()), grid.semantic_search_left(end.into()))
+ }
+ } else if start < end && start.line == end.line {
(grid.semantic_search_left(start.into()), grid.semantic_search_right(end.into()))
} else {
(grid.semantic_search_right(start.into()), grid.semantic_search_left(end.into()))
};
if start > end {
- ::std::mem::swap(&mut start, &mut end);
+ std::mem::swap(&mut start, &mut end);
}
Some(Span { start, end })