diff --git a/apply.go b/apply.go index d5ada7a..ff5605a 100644 --- a/apply.go +++ b/apply.go @@ -208,7 +208,11 @@ func eatLines(scan *bufio.Scanner, prefix string, n int) error { if !scan.Scan() { return io.ErrUnexpectedEOF } - if !bytes.HasPrefix(scan.Bytes(), bprefix) { + // diff can inject comments in lines beginning with a backslash, like when + // highlighting that the original line had no trailing newline + if bytes.HasPrefix(scan.Bytes(), []byte("\\ ")) { + i-- + } else if !bytes.HasPrefix(scan.Bytes(), bprefix) { return fmt.Errorf("line %q does not have expected prefix %q", scan.Bytes(), bprefix) } } diff --git a/go.mod b/go.mod index b7d9a48..7e956c3 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,5 @@ module github.com/rogpeppe/apipe require 9fans.net/go v0.0.0-20180727211846-5d4fa602e1e8 + +go 1.13