aboutsummaryrefslogtreecommitdiff
path: root/crates/libeditor/src/extend_selection.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-08-11 10:28:59 +0100
committerAleksey Kladov <[email protected]>2018-08-11 10:28:59 +0100
commit7afd84febc76a75a3ed1be75c57ff35d7b8b3de6 (patch)
tree76eb2de7efc569c39cc721b7be298490b9647e0b /crates/libeditor/src/extend_selection.rs
parentd5119133fc03694c6644cac9e307d1d496fc9bf2 (diff)
visitor
Diffstat (limited to 'crates/libeditor/src/extend_selection.rs')
-rw-r--r--crates/libeditor/src/extend_selection.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/crates/libeditor/src/extend_selection.rs b/crates/libeditor/src/extend_selection.rs
index 16d4bc084..ed7d9b3f7 100644
--- a/crates/libeditor/src/extend_selection.rs
+++ b/crates/libeditor/src/extend_selection.rs
@@ -1,11 +1,16 @@
1use libsyntax2::{ 1use libsyntax2::{
2 ast, AstNode,
2 TextRange, SyntaxNodeRef, 3 TextRange, SyntaxNodeRef,
3 SyntaxKind::WHITESPACE, 4 SyntaxKind::WHITESPACE,
4 algo::{find_leaf_at_offset, find_covering_node, ancestors}, 5 algo::{find_leaf_at_offset, find_covering_node, ancestors},
5}; 6};
6 7
8pub fn extend_selection(file: &ast::File, range: TextRange) -> Option<TextRange> {
9 let syntax = file.syntax();
10 extend(syntax.as_ref(), range)
11}
7 12
8pub(crate) fn extend_selection(root: SyntaxNodeRef, range: TextRange) -> Option<TextRange> { 13pub(crate) fn extend(root: SyntaxNodeRef, range: TextRange) -> Option<TextRange> {
9 if range.is_empty() { 14 if range.is_empty() {
10 let offset = range.start(); 15 let offset = range.start();
11 let mut leaves = find_leaf_at_offset(root, offset); 16 let mut leaves = find_leaf_at_offset(root, offset);