diff options
author | Bernardo <[email protected]> | 2018-12-08 19:53:03 +0000 |
---|---|---|
committer | Bernardo <[email protected]> | 2018-12-08 19:53:03 +0000 |
commit | 6fb267f5da9acb78f89a6ab0cedf7d1f904b16c3 (patch) | |
tree | 3fb667422899d19edd914fa9e65d586ace62b0aa /crates/ra_editor/src | |
parent | 97b07ac393caebaa76099f97672ad4399c0ceda6 (diff) |
find next whitespace or begining or end
Diffstat (limited to 'crates/ra_editor/src')
-rw-r--r-- | crates/ra_editor/src/extend_selection.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/crates/ra_editor/src/extend_selection.rs b/crates/ra_editor/src/extend_selection.rs index b4227716d..a2aa02149 100644 --- a/crates/ra_editor/src/extend_selection.rs +++ b/crates/ra_editor/src/extend_selection.rs | |||
@@ -48,8 +48,8 @@ fn extend_single_word_in_comment(leaf: SyntaxNodeRef, offset: TextUnit) -> Optio | |||
48 | let cursor_position: u32 = (offset - leaf.range().start()).into(); | 48 | let cursor_position: u32 = (offset - leaf.range().start()).into(); |
49 | 49 | ||
50 | let (before, after) = text.split_at(cursor_position as usize); | 50 | let (before, after) = text.split_at(cursor_position as usize); |
51 | let start_idx = before.rfind(char::is_whitespace)? as u32; | 51 | let start_idx = before.rfind(char::is_whitespace).unwrap_or(0) as u32; |
52 | let end_idx = after.find(char::is_whitespace)? as u32; | 52 | let end_idx = after.find(char::is_whitespace).unwrap_or(after.len()) as u32; |
53 | 53 | ||
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(); |
@@ -184,7 +184,7 @@ fn bar(){} | |||
184 | 184 | ||
185 | // fn foo(){} | 185 | // fn foo(){} |
186 | "#, | 186 | "#, |
187 | &["// 1 + 1", "// fn foo() {\n// 1 + 1\n// }"], | 187 | &["1", "// 1 + 1", "// fn foo() {\n// 1 + 1\n// }"], |
188 | ); | 188 | ); |
189 | 189 | ||
190 | do_check( | 190 | do_check( |