From 12e3b4c70b5ef23b2fdfc197296d483680e125f9 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 8 Feb 2019 14:49:43 +0300 Subject: reformat the world --- crates/ra_ide_api_light/src/extend_selection.rs | 57 +++++-------------------- 1 file changed, 11 insertions(+), 46 deletions(-) (limited to 'crates/ra_ide_api_light/src/extend_selection.rs') diff --git a/crates/ra_ide_api_light/src/extend_selection.rs b/crates/ra_ide_api_light/src/extend_selection.rs index f396dfe3f..28d62f290 100644 --- a/crates/ra_ide_api_light/src/extend_selection.rs +++ b/crates/ra_ide_api_light/src/extend_selection.rs @@ -43,11 +43,7 @@ pub fn extend_selection(root: &SyntaxNode, range: TextRange) -> Option Option { } if let Some(comma_node) = nearby_comma(node, Direction::Prev) { - return Some(TextRange::from_to( - comma_node.range().start(), - node.range().end(), - )); + return Some(TextRange::from_to(comma_node.range().start(), node.range().end())); } if let Some(comma_node) = nearby_comma(node, Direction::Next) { @@ -160,10 +153,7 @@ fn extend_list_item(node: &SyntaxNode) -> Option { .filter(|node| is_single_line_ws(node)) .unwrap_or(comma_node); - return Some(TextRange::from_to( - node.range().start(), - final_node.range().end(), - )); + return Some(TextRange::from_to(node.range().start(), final_node.range().end())); } return None; @@ -217,36 +207,15 @@ mod tests { #[test] fn test_extend_selection_list() { do_check(r#"fn foo(<|>x: i32) {}"#, &["x", "x: i32"]); - do_check( - r#"fn foo(<|>x: i32, y: i32) {}"#, - &["x", "x: i32", "x: i32, "], - ); - do_check( - r#"fn foo(<|>x: i32,y: i32) {}"#, - &["x", "x: i32", "x: i32,"], - ); - do_check( - r#"fn foo(x: i32, <|>y: i32) {}"#, - &["y", "y: i32", ", y: i32"], - ); - do_check( - r#"fn foo(x: i32, <|>y: i32, ) {}"#, - &["y", "y: i32", ", y: i32"], - ); - do_check( - r#"fn foo(x: i32,<|>y: i32) {}"#, - &["y", "y: i32", ",y: i32"], - ); + do_check(r#"fn foo(<|>x: i32, y: i32) {}"#, &["x", "x: i32", "x: i32, "]); + do_check(r#"fn foo(<|>x: i32,y: i32) {}"#, &["x", "x: i32", "x: i32,"]); + do_check(r#"fn foo(x: i32, <|>y: i32) {}"#, &["y", "y: i32", ", y: i32"]); + do_check(r#"fn foo(x: i32, <|>y: i32, ) {}"#, &["y", "y: i32", ", y: i32"]); + do_check(r#"fn foo(x: i32,<|>y: i32) {}"#, &["y", "y: i32", ",y: i32"]); - do_check( - r#"const FOO: [usize; 2] = [ 22<|> , 33];"#, - &["22", "22 , "], - ); + do_check(r#"const FOO: [usize; 2] = [ 22<|> , 33];"#, &["22", "22 , "]); do_check(r#"const FOO: [usize; 2] = [ 22 , 33<|>];"#, &["33", ", 33"]); - do_check( - r#"const FOO: [usize; 2] = [ 22 , 33<|> ,];"#, - &["33", ", 33"], - ); + do_check(r#"const FOO: [usize; 2] = [ 22 , 33<|> ,];"#, &["33", ", 33"]); do_check( r#" @@ -292,11 +261,7 @@ struct B { <|> } "#, - &[ - "\n \n", - "{\n \n}", - "/// bla\n/// bla\nstruct B {\n \n}", - ], + &["\n \n", "{\n \n}", "/// bla\n/// bla\nstruct B {\n \n}"], ) } -- cgit v1.2.3