Fix parsing of diff hunk headers with omitted length

7dd76231e6 made the comma and the second
number required in a line range. But they can be omitted, for example:

* Adding a single line file:

    @@ -0,0 +1 @@

* Modifying a single line file:

    @@ -1 +1 @@
This commit is contained in:
Maksim Odnoletkov
2022-12-02 10:23:58 +00:00
committed by Tim Pope
parent 49cc58573e
commit 5b0b138483

View File

@@ -7599,7 +7599,7 @@ function! s:HunkPosition(lnum) abort
let lnum -= 1
let line_char = getline(lnum)[0]
endwhile
let starts = matchlist(getline(lnum), '^@@\+[ 0-9,-]* -\(\d\+\),\d\+ +\(\d\+\),')
let starts = matchlist(getline(lnum), '^@@\+[ 0-9,-]* -\(\d\+\)\%(,\d\+\)\= +\(\d\+\)[ ,]')
if empty(starts)
return [0, 0, 0]
endif