From 50b2edb8826fdc86fea82b3ba9da15902d151dbe Mon Sep 17 00:00:00 2001 From: Kevin Amado Date: Sun, 6 Feb 2022 20:15:30 -0500 Subject: [PATCH] fix: stable let in - I was using the previous position to compute the new position, but this causes the let in to not converge into a single round - This way let in converge into a single round, as promised in the README --- src/children.rs | 9 ++++++--- src/rules/let_in.rs | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/children.rs b/src/children.rs index 965bc12..13aa837 100644 --- a/src/children.rs +++ b/src/children.rs @@ -20,9 +20,12 @@ impl Children { for child in node.children_with_tokens() { match child { - rnix::SyntaxElement::Node(_) => { - children - .push(Child { element: child, pos: pos.clone() }); + rnix::SyntaxElement::Node(node) => { + children.push(Child { + element: node.clone().into(), + pos: pos.clone(), + }); + pos.update(&node.text().to_string()); } rnix::SyntaxElement::Token(token) => { match token.kind() { diff --git a/src/rules/let_in.rs b/src/rules/let_in.rs index 3990c9f..7aa5b01 100644 --- a/src/rules/let_in.rs +++ b/src/rules/let_in.rs @@ -82,7 +82,7 @@ pub fn rule( // in let child = children.get_next().unwrap(); - let indent = child.pos.column > 1; + let indent = build_ctx.pos_new.column > 1; match layout { crate::config::Layout::Tall => { steps.push_back(crate::builder::Step::Dedent);