diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-02-21 16:55:26 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-02-21 16:55:26 +0000 |
commit | 5100aeac429919d1758908efb2f9cbe0d02c7510 (patch) | |
tree | 5921ac7c9d20fa729a3d97d8e6a81f87431f57e3 /crates/ra_assists/src | |
parent | 55da8e786d2cac3cb6332f80c1ee715fbcbdee0d (diff) | |
parent | 82173c8de4b1283b6b54bd0def25b9c432614841 (diff) |
Merge #876
876: Fix join_lines not adding a comma after join_single_expr_block with match arm r=matklad a=vipentti
Fixes #868
Co-authored-by: Ville Penttinen <[email protected]>
Diffstat (limited to 'crates/ra_assists/src')
-rw-r--r-- | crates/ra_assists/src/flip_comma.rs | 3 | ||||
-rw-r--r-- | crates/ra_assists/src/lib.rs | 6 |
2 files changed, 3 insertions, 6 deletions
diff --git a/crates/ra_assists/src/flip_comma.rs b/crates/ra_assists/src/flip_comma.rs index 08644d720..0d4a789fc 100644 --- a/crates/ra_assists/src/flip_comma.rs +++ b/crates/ra_assists/src/flip_comma.rs | |||
@@ -2,9 +2,10 @@ use hir::db::HirDatabase; | |||
2 | use ra_syntax::{ | 2 | use ra_syntax::{ |
3 | Direction, | 3 | Direction, |
4 | SyntaxKind::COMMA, | 4 | SyntaxKind::COMMA, |
5 | algo::non_trivia_sibling, | ||
5 | }; | 6 | }; |
6 | 7 | ||
7 | use crate::{AssistCtx, Assist, non_trivia_sibling}; | 8 | use crate::{AssistCtx, Assist}; |
8 | 9 | ||
9 | pub(crate) fn flip_comma(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 10 | pub(crate) fn flip_comma(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { |
10 | let comma = ctx.leaf_at_offset().find(|leaf| leaf.kind() == COMMA)?; | 11 | let comma = ctx.leaf_at_offset().find(|leaf| leaf.kind() == COMMA)?; |
diff --git a/crates/ra_assists/src/lib.rs b/crates/ra_assists/src/lib.rs index 7bd9b5ae6..e1e899edc 100644 --- a/crates/ra_assists/src/lib.rs +++ b/crates/ra_assists/src/lib.rs | |||
@@ -10,7 +10,7 @@ mod assist_ctx; | |||
10 | use itertools::Itertools; | 10 | use itertools::Itertools; |
11 | 11 | ||
12 | use ra_text_edit::TextEdit; | 12 | use ra_text_edit::TextEdit; |
13 | use ra_syntax::{TextRange, TextUnit, SyntaxNode, Direction}; | 13 | use ra_syntax::{TextRange, TextUnit}; |
14 | use ra_db::FileRange; | 14 | use ra_db::FileRange; |
15 | use hir::db::HirDatabase; | 15 | use hir::db::HirDatabase; |
16 | 16 | ||
@@ -104,10 +104,6 @@ fn all_assists<DB: HirDatabase>() -> &'static [fn(AssistCtx<DB>) -> Option<Assis | |||
104 | ] | 104 | ] |
105 | } | 105 | } |
106 | 106 | ||
107 | fn non_trivia_sibling(node: &SyntaxNode, direction: Direction) -> Option<&SyntaxNode> { | ||
108 | node.siblings(direction).skip(1).find(|node| !node.kind().is_trivia()) | ||
109 | } | ||
110 | |||
111 | #[cfg(test)] | 107 | #[cfg(test)] |
112 | mod helpers { | 108 | mod helpers { |
113 | use hir::mock::MockDatabase; | 109 | use hir::mock::MockDatabase; |