aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_editor/src/extend_selection.rs21
1 files changed, 20 insertions, 1 deletions
diff --git a/crates/ra_editor/src/extend_selection.rs b/crates/ra_editor/src/extend_selection.rs
index 8f11d5364..b4227716d 100644
--- a/crates/ra_editor/src/extend_selection.rs
+++ b/crates/ra_editor/src/extend_selection.rs
@@ -54,7 +54,12 @@ fn extend_single_word_in_comment(leaf: SyntaxNodeRef, offset: TextUnit) -> Optio
54 let from: TextUnit = (start_idx + 1).into(); 54 let from: TextUnit = (start_idx + 1).into();
55 let to: TextUnit = (cursor_position + end_idx).into(); 55 let to: TextUnit = (cursor_position + end_idx).into();
56 56
57 Some(TextRange::from_to(from, to) + leaf.range().start()) 57 let range = TextRange::from_to(from, to);
58 if range.is_empty() {
59 None
60 } else {
61 Some(range + leaf.range().start())
62 }
58} 63}
59 64
60fn extend_ws(root: SyntaxNodeRef, ws: SyntaxNodeRef, offset: TextUnit) -> TextRange { 65fn extend_ws(root: SyntaxNodeRef, ws: SyntaxNodeRef, offset: TextUnit) -> TextRange {
@@ -181,6 +186,20 @@ fn bar(){}
181 "#, 186 "#,
182 &["// 1 + 1", "// fn foo() {\n// 1 + 1\n// }"], 187 &["// 1 + 1", "// fn foo() {\n// 1 + 1\n// }"],
183 ); 188 );
189
190 do_check(
191 r#"
192// #[derive(Debug, Clone, Copy, PartialEq, Eq)]
193// pub enum Direction {
194// <|> Next,
195// Prev
196// }
197"#,
198 &[
199 "// Next,",
200 "// #[derive(Debug, Clone, Copy, PartialEq, Eq)]\n// pub enum Direction {\n// Next,\n// Prev\n// }",
201 ],
202 );
184 } 203 }
185 204
186 #[test] 205 #[test]