tools/patches/d2/402_preserve_leading_comment_spacing.patch

24 lines
543 B
Diff
Raw Normal View History

2022-12-12 23:14:38 +03:00
diff --git a/d2format/format.go b/d2format/format.go
index 754e3302..a45d55f6 100644
--- a/d2format/format.go
+++ b/d2format/format.go
@@ -76,17 +76,17 @@ func (p *printer) node(n d2ast.Node) {
p.edgeIndex(n)
}
}
func (p *printer) comment(c *d2ast.Comment) {
lines := strings.Split(c.Value, "\n")
for i, line := range lines {
p.sb.WriteString("#")
- if line != "" && !strings.HasPrefix(line, " ") {
+ if line != "" {
p.sb.WriteByte(' ')
}
p.sb.WriteString(line)
if i < len(lines)-1 {
p.newline()
}
}
}