From ae1270f3c76ade9b6b88a7657ae9994025194bf5 Mon Sep 17 00:00:00 2001 From: Roger Peppe Date: Fri, 17 Dec 2021 13:03:30 +0000 Subject: [PATCH] acme/acmego: allow append at 0 When a line is being added to the start of a document (a classic example being when `gofmt` adds a `//go:build` line), the diff logic was ignoring it and thus always thinking that the file needed changes without ever actually applying the changes. --- acme/acmego/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acme/acmego/main.go b/acme/acmego/main.go index 32e245e..82567d8 100644 --- a/acme/acmego/main.go +++ b/acme/acmego/main.go @@ -178,7 +178,7 @@ func reformat(id int, name string, formatter []string) { } oldStart, oldEnd := parseSpan(line[:j]) newStart, newEnd := parseSpan(line[j+1:]) - if oldStart == 0 || newStart == 0 { + if newStart == 0 || (oldStart == 0 && line[j] != 'a') { continue } switch line[j] {