From 8cad7d1a2b2546986aa8f42207875b1c8eed948a Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 9 Jun 2020 12:38:47 +0200 Subject: Use correct indent when replacing with match --- crates/ra_syntax/src/ast/edit.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'crates/ra_syntax/src/ast') diff --git a/crates/ra_syntax/src/ast/edit.rs b/crates/ra_syntax/src/ast/edit.rs index 29eb3fcb9..2ef173a03 100644 --- a/crates/ra_syntax/src/ast/edit.rs +++ b/crates/ra_syntax/src/ast/edit.rs @@ -579,12 +579,17 @@ pub trait AstNodeEdit: AstNode + Clone + Sized { rewriter.rewrite_ast(self) } #[must_use] - fn indent(&self, indent: IndentLevel) -> Self { - Self::cast(indent.increase_indent(self.syntax().clone())).unwrap() + fn indent(&self, level: IndentLevel) -> Self { + Self::cast(level.increase_indent(self.syntax().clone())).unwrap() } #[must_use] - fn dedent(&self, indent: IndentLevel) -> Self { - Self::cast(indent.decrease_indent(self.syntax().clone())).unwrap() + fn dedent(&self, level: IndentLevel) -> Self { + Self::cast(level.decrease_indent(self.syntax().clone())).unwrap() + } + #[must_use] + fn reset_indent(&self) -> Self { + let level = IndentLevel::from_node(self.syntax()); + self.dedent(level) } } -- cgit v1.2.3