diff options
author | Jean Mertz <jean@mertz.fm> | 2019-05-11 18:15:32 +0200 |
---|---|---|
committer | Christian Duerr <chrisduerr@users.noreply.github.com> | 2019-05-11 16:15:32 +0000 |
commit | 1656aff85ed7412fd6ab8a7f75384f86d98a483b (patch) | |
tree | 6c8f2202ef8ce19f6098dee2e3087bf4dc8cb8a3 /alacritty_terminal/src/selection.rs | |
parent | ca9724a5efe38a2db47d1b44b9d9f75cb6b6d20e (diff) | |
download | alacritty-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.rs | 10 |
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 }) |