From 6fb267f5da9acb78f89a6ab0cedf7d1f904b16c3 Mon Sep 17 00:00:00 2001 From: Bernardo Date: Sat, 8 Dec 2018 20:53:03 +0100 Subject: find next whitespace or begining or end --- crates/ra_editor/src/extend_selection.rs | 6 +++--- 1 file 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 let cursor_position: u32 = (offset - leaf.range().start()).into(); let (before, after) = text.split_at(cursor_position as usize); - let start_idx = before.rfind(char::is_whitespace)? as u32; - let end_idx = after.find(char::is_whitespace)? as u32; + let start_idx = before.rfind(char::is_whitespace).unwrap_or(0) as u32; + let end_idx = after.find(char::is_whitespace).unwrap_or(after.len()) as u32; let from: TextUnit = (start_idx + 1).into(); let to: TextUnit = (cursor_position + end_idx).into(); @@ -184,7 +184,7 @@ fn bar(){} // fn foo(){} "#, - &["// 1 + 1", "// fn foo() {\n// 1 + 1\n// }"], + &["1", "// 1 + 1", "// fn foo() {\n// 1 + 1\n// }"], ); do_check( -- cgit v1.2.3