Skip to content

Commit 5726eda

Browse files
committed
Handle peek beyond last line
1 parent 45f0055 commit 5726eda

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

diff/parse.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,9 @@ func linePrefix(c byte) bool {
598598
func nextLineHasPrefix(reader *bufio.Reader, prefix []byte) (bool, error) {
599599
next, err := reader.Peek(len(prefix))
600600
if err != nil {
601+
if err == io.EOF {
602+
return false, nil
603+
}
601604
return false, err
602605
}
603606
return bytes.HasPrefix(next, prefix), nil
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
@@ -1,4 +1,3 @@
1+
@@ -1,5 +1,3 @@
22
select 1;
33
--- this is my query
44
select 2;
55
select 3;
6+
--- this is the last line

0 commit comments

Comments
 (0)