Only pre-size the printer buffer when printing a whole file (#64972)

This commit is contained in:
Jake Bailey authored and GitHub committed 2026-10-27 16:18:00 +00:00
1 parent 49e6983021
commit 1f82f368b6
1 file changed
+1 -1
+1 -1
View File
@@ -5095,7 +5095,7 @@ func (p *Printer) Write(node *ast.Node, sourceFile *ast.SourceFile, writer EmitT
}
p.writer = writer
p.writer.Clear()
if sourceFile != nil {
if sourceFile != nil && node == sourceFile.AsNode() {
if grower, ok := p.writer.(interface{ Grow(n int) }); ok {
grower.Grow(len(sourceFile.Text()))
}