Use correct indent when replacing with match

This commit is contained in:
Aleksey Kladov 2020-06-09 12:38:47 +02:00
parent 53cc2c16e7
commit 8cad7d1a2b
3 changed files with 45 additions and 7 deletions

View file

@ -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)
}
}