update to latest dependencies

This commit is contained in:
Mechiel Lukkien
2023-07-03 09:13:19 +02:00
parent 88d063b598
commit c2448e5adc
37 changed files with 671 additions and 76 deletions

View File

@ -16,7 +16,13 @@ import (
func Format(f *FileSyntax) []byte {
pr := &printer{}
pr.file(f)
return pr.Bytes()
// remove trailing blank lines
b := pr.Bytes()
for len(b) > 0 && b[len(b)-1] == '\n' && (len(b) == 1 || b[len(b)-2] == '\n') {
b = b[:len(b)-1]
}
return b
}
// A printer collects the state during printing of a file or expression.
@ -59,7 +65,11 @@ func (p *printer) newline() {
}
p.trim()
p.printf("\n")
if b := p.Bytes(); len(b) == 0 || (len(b) >= 2 && b[len(b)-1] == '\n' && b[len(b)-2] == '\n') {
// skip the blank line at top of file or after a blank line
} else {
p.printf("\n")
}
for i := 0; i < p.margin; i++ {
p.printf("\t")
}