dualfroz 71779310b7 fix(printer): keep indentation of nested <<- heredoc inside command substitution
A <<- heredoc nested inside a command substitution that is itself inside
another <<- heredoc was printed with its body fully deindented and its end
marker pushed one extra tab further per body line.

When both heredocs use tab indentation, the printer wraps each body in an
extraIndenter. In the nested case the inner extraIndenter writes to the outer
one. Its computed indentation was emitted via WriteByte (which the outer
extraIndenter processes line by line), but the line content was emitted via
Write, whose method set is promoted straight to the embedded writer and so
bypassed the outer extraIndenter entirely. The content reached the tab writer
without the outer indentation, while the orphaned indentation bytes stayed
buffered and leaked onto the following end-marker line.

Emit the trimmed content through WriteString so nested extraIndenters compose,
keeping both the body and the end marker correctly indented.

Add printer golden tests for single- and multi-line nested tab heredocs.
2026-08-27 23:41:17 +02:00
S
Description
My contributions to mvdan/sh: 1 commits
71 KiB
0 Stars 1 Watchers 0 Forks
Languages
Go 100%