diff options
author | Aleksey Kladov <[email protected]> | 2019-02-08 11:49:43 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-02-08 11:49:43 +0000 |
commit | 12e3b4c70b5ef23b2fdfc197296d483680e125f9 (patch) | |
tree | 71baa0e0a62f9f6b61450501c5f821f67badf9e4 /crates/ra_ide_api_light/src/typing.rs | |
parent | 5cb1d41a30d25cbe136402644bf5434dd667f1e5 (diff) |
reformat the world
Diffstat (limited to 'crates/ra_ide_api_light/src/typing.rs')
-rw-r--r-- | crates/ra_ide_api_light/src/typing.rs | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/crates/ra_ide_api_light/src/typing.rs b/crates/ra_ide_api_light/src/typing.rs index 861027b9f..a08a5a8c5 100644 --- a/crates/ra_ide_api_light/src/typing.rs +++ b/crates/ra_ide_api_light/src/typing.rs | |||
@@ -8,9 +8,8 @@ use ra_syntax::{ | |||
8 | use crate::{LocalEdit, TextEditBuilder, formatting::leading_indent}; | 8 | use crate::{LocalEdit, TextEditBuilder, formatting::leading_indent}; |
9 | 9 | ||
10 | pub fn on_enter(file: &SourceFile, offset: TextUnit) -> Option<LocalEdit> { | 10 | pub fn on_enter(file: &SourceFile, offset: TextUnit) -> Option<LocalEdit> { |
11 | let comment = find_leaf_at_offset(file.syntax(), offset) | 11 | let comment = |
12 | .left_biased() | 12 | find_leaf_at_offset(file.syntax(), offset).left_biased().and_then(ast::Comment::cast)?; |
13 | .and_then(ast::Comment::cast)?; | ||
14 | 13 | ||
15 | if let ast::CommentFlavor::Multiline = comment.flavor() { | 14 | if let ast::CommentFlavor::Multiline = comment.flavor() { |
16 | return None; | 15 | return None; |
@@ -64,12 +63,7 @@ pub fn on_eq_typed(file: &SourceFile, eq_offset: TextUnit) -> Option<LocalEdit> | |||
64 | if expr_range.contains(eq_offset) && eq_offset != expr_range.start() { | 63 | if expr_range.contains(eq_offset) && eq_offset != expr_range.start() { |
65 | return None; | 64 | return None; |
66 | } | 65 | } |
67 | if file | 66 | if file.syntax().text().slice(eq_offset..expr_range.start()).contains('\n') { |
68 | .syntax() | ||
69 | .text() | ||
70 | .slice(eq_offset..expr_range.start()) | ||
71 | .contains('\n') | ||
72 | { | ||
73 | return None; | 67 | return None; |
74 | } | 68 | } |
75 | } else { | 69 | } else { |
@@ -100,10 +94,7 @@ pub fn on_dot_typed(file: &SourceFile, dot_offset: TextUnit) -> Option<LocalEdit | |||
100 | let current_indent_len = TextUnit::of_str(current_indent); | 94 | let current_indent_len = TextUnit::of_str(current_indent); |
101 | 95 | ||
102 | // Make sure dot is a part of call chain | 96 | // Make sure dot is a part of call chain |
103 | let field_expr = whitespace | 97 | let field_expr = whitespace.syntax().parent().and_then(ast::FieldExpr::cast)?; |
104 | .syntax() | ||
105 | .parent() | ||
106 | .and_then(ast::FieldExpr::cast)?; | ||
107 | let prev_indent = leading_indent(field_expr.syntax())?; | 98 | let prev_indent = leading_indent(field_expr.syntax())?; |
108 | let target_indent = format!(" {}", prev_indent); | 99 | let target_indent = format!(" {}", prev_indent); |
109 | let target_indent_len = TextUnit::of_str(&target_indent); | 100 | let target_indent_len = TextUnit::of_str(&target_indent); |