aboutsummaryrefslogtreecommitdiff
path: root/crates/libeditor/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-08-22 09:56:36 +0100
committerAleksey Kladov <[email protected]>2018-08-22 09:56:36 +0100
commit641659d5a8dcca0b8a1c36ff6d1c517a91296116 (patch)
tree8ed23d27c1839d525cd69be56bbba2fb6cf52598 /crates/libeditor/src
parent9909875bfe89d2b901c35c0667bed018338b44e1 (diff)
Smarter extend selection
Diffstat (limited to 'crates/libeditor/src')
-rw-r--r--crates/libeditor/src/extend_selection.rs20
1 files changed, 8 insertions, 12 deletions
diff --git a/crates/libeditor/src/extend_selection.rs b/crates/libeditor/src/extend_selection.rs
index 171e40692..32873f491 100644
--- a/crates/libeditor/src/extend_selection.rs
+++ b/crates/libeditor/src/extend_selection.rs
@@ -17,18 +17,14 @@ pub(crate) fn extend(root: SyntaxNodeRef, range: TextRange) -> Option<TextRange>
17 return Some(leaf.range()); 17 return Some(leaf.range());
18 } 18 }
19 let ws = leaves.next()?; 19 let ws = leaves.next()?;
20// let ws_suffix = file.text().slice( 20 let ws_text = ws.leaf_text().unwrap();
21// TextRange::from_to(offset, ws.range().end()) 21 let range = TextRange::from_to(offset, ws.range().end()) - ws.range().start();
22// ); 22 let ws_suffix = &ws_text.as_str()[range];
23// if ws.text().contains("\n") && !ws_suffix.contains("\n") { 23 if ws_text.contains("\n") && !ws_suffix.contains("\n") {
24// if let Some(line_end) = file.text() 24 if let Some(node) = ws.next_sibling() {
25// .slice(TextSuffix::from(ws.range().end())) 25 return Some(node.range());
26// .find("\n") 26 }
27// { 27 }
28// let range = TextRange::from_len(ws.range().end(), line_end);
29// return Some(find_covering_node(file.root(), range).range());
30// }
31// }
32 return Some(ws.range()); 28 return Some(ws.range());
33 }; 29 };
34 let node = find_covering_node(root, range); 30 let node = find_covering_node(root, range);