fix(cli): trailing whitespace after multiline text nodes in CST

Problem:
The CST printer emits trailing whitespace after multiline text nodes.
With 1704c604bf 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.
This commit is contained in:
skewb1k 2025-12-15 01:20:19 +03:00 committed by Will Lillis
parent 642b56d9af
commit 4ac2d5d276

View file

@ -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,