diff options
Diffstat (limited to 'crates/ra_editor/src/typing.rs')
-rw-r--r-- | crates/ra_editor/src/typing.rs | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/crates/ra_editor/src/typing.rs b/crates/ra_editor/src/typing.rs index f0d8dc7bb..21d068a7b 100644 --- a/crates/ra_editor/src/typing.rs +++ b/crates/ra_editor/src/typing.rs | |||
@@ -8,9 +8,8 @@ use ra_syntax::{ | |||
8 | SyntaxKind::*, | 8 | SyntaxKind::*, |
9 | SyntaxNodeRef, TextRange, TextUnit, | 9 | SyntaxNodeRef, TextRange, TextUnit, |
10 | }; | 10 | }; |
11 | use ra_text_edit::text_utils::{ | 11 | use ra_text_edit::text_utils::contains_offset_nonstrict; |
12 | contains_offset_nonstrict | 12 | use itertools::Itertools; |
13 | }; | ||
14 | 13 | ||
15 | use crate::{find_node_at_offset, TextEditBuilder, LocalEdit}; | 14 | use crate::{find_node_at_offset, TextEditBuilder, LocalEdit}; |
16 | 15 | ||
@@ -246,7 +245,7 @@ fn single_expr(block: ast::Block) -> Option<ast::Expr> { | |||
246 | 245 | ||
247 | fn join_single_use_tree(edit: &mut TextEditBuilder, node: SyntaxNodeRef) -> Option<()> { | 246 | fn join_single_use_tree(edit: &mut TextEditBuilder, node: SyntaxNodeRef) -> Option<()> { |
248 | let use_tree_list = ast::UseTreeList::cast(node.parent()?)?; | 247 | let use_tree_list = ast::UseTreeList::cast(node.parent()?)?; |
249 | let tree = single_use_tree(use_tree_list)?; | 248 | let (tree,) = use_tree_list.use_trees().collect_tuple()?; |
250 | edit.replace( | 249 | edit.replace( |
251 | use_tree_list.syntax().range(), | 250 | use_tree_list.syntax().range(), |
252 | tree.syntax().text().to_string(), | 251 | tree.syntax().text().to_string(), |
@@ -254,15 +253,6 @@ fn join_single_use_tree(edit: &mut TextEditBuilder, node: SyntaxNodeRef) -> Opti | |||
254 | Some(()) | 253 | Some(()) |
255 | } | 254 | } |
256 | 255 | ||
257 | fn single_use_tree(tree_list: ast::UseTreeList) -> Option<ast::UseTree> { | ||
258 | let sub_use_trees = tree_list.use_trees().count(); | ||
259 | if sub_use_trees != 1 { | ||
260 | return None; | ||
261 | } | ||
262 | |||
263 | tree_list.use_trees().next() | ||
264 | } | ||
265 | |||
266 | fn compute_ws(left: SyntaxNodeRef, right: SyntaxNodeRef) -> &'static str { | 256 | fn compute_ws(left: SyntaxNodeRef, right: SyntaxNodeRef) -> &'static str { |
267 | match left.kind() { | 257 | match left.kind() { |
268 | L_PAREN | L_BRACK => return "", | 258 | L_PAREN | L_BRACK => return "", |