From 4ac2d5d2761552d322bd51e011ecb6bfbd7a9253 Mon Sep 17 00:00:00 2001 From: skewb1k Date: Mon, 15 Dec 2025 01:20:19 +0300 Subject: [PATCH] fix(cli): trailing whitespace after multiline text nodes in CST Problem: The CST printer emits trailing whitespace after multiline text nodes. With 1704c604bf663801876572fe08b746e787cd7fdb and `:cst` corpus tests this causes trailing spaces to appear on `test --update`. These spaces cannot be removed afterward, as the test runner expects an exact character-for-character match for CST tests. Solution: Print whitespace only if node is not multiline. --- crates/cli/src/parse.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/cli/src/parse.rs b/crates/cli/src/parse.rs index 1023b0fc..292b3614 100644 --- a/crates/cli/src/parse.rs +++ b/crates/cli/src/parse.rs @@ -887,7 +887,7 @@ fn write_node_text( write!( out, "{}{}{}{}{}{}", - if multiline { "\n" } else { "" }, + if multiline { "\n" } else { " " }, if multiline { render_node_range(opts, cursor, is_named, true, total_width, node_range) } else { @@ -1011,10 +1011,9 @@ fn cst_render_node( } else { opts.parse_theme.node_kind }; - write!(out, "{}", paint(kind_color, node.kind()),)?; + write!(out, "{}", paint(kind_color, node.kind()))?; if node.child_count() == 0 { - write!(out, " ")?; // Node text from a pattern or external scanner write_node_text( opts,