diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-01-11 12:49:09 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-01-11 12:49:09 +0000 |
commit | 0f4bc7589c40732fb78cb59525a6b4dcfb515567 (patch) | |
tree | 4ff25038c52dc1767579135bb5387b0fb184c83d /crates/ra_ide_api_light/src/formatting.rs | |
parent | dd122145b57513cf57076ae3235d70215b226039 (diff) | |
parent | a1b661faec69e5c643924bf672ac61ff4ff12202 (diff) |
Merge #495
495: Fix on type handlers r=matklad a=matklad
Looks like our on type handlers didn't actually worked, this shoud fix that!
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_ide_api_light/src/formatting.rs')
-rw-r--r-- | crates/ra_ide_api_light/src/formatting.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/crates/ra_ide_api_light/src/formatting.rs b/crates/ra_ide_api_light/src/formatting.rs index 1f3769209..4635fbd60 100644 --- a/crates/ra_ide_api_light/src/formatting.rs +++ b/crates/ra_ide_api_light/src/formatting.rs | |||
@@ -1,8 +1,16 @@ | |||
1 | use ra_syntax::{ | 1 | use ra_syntax::{ |
2 | ast, AstNode, | 2 | AstNode, |
3 | SyntaxNode, SyntaxKind::*, | 3 | SyntaxNode, SyntaxKind::*, |
4 | ast::{self, AstToken}, | ||
4 | }; | 5 | }; |
5 | 6 | ||
7 | /// If the node is on the begining of the line, calculate indent. | ||
8 | pub(crate) fn leading_indent(node: &SyntaxNode) -> Option<&str> { | ||
9 | let prev = node.prev_sibling()?; | ||
10 | let ws_text = ast::Whitespace::cast(prev)?.text(); | ||
11 | ws_text.rfind('\n').map(|pos| &ws_text[pos + 1..]) | ||
12 | } | ||
13 | |||
6 | pub(crate) fn extract_trivial_expression(block: &ast::Block) -> Option<&ast::Expr> { | 14 | pub(crate) fn extract_trivial_expression(block: &ast::Block) -> Option<&ast::Expr> { |
7 | let expr = block.expr()?; | 15 | let expr = block.expr()?; |
8 | if expr.syntax().text().contains('\n') { | 16 | if expr.syntax().text().contains('\n') { |