Skip to content

Commit ceb0791

Browse files
committed
fix: match from the start of the line when building hunks, or .diff files will be shown incorrectly
1 parent 108985c commit ceb0791

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lua/neogit/lib/git/diff.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,10 @@ local function build_hunks(lines)
168168

169169
if line:match("^@@@") then
170170
-- Combined diff header
171-
index_from, index_len, disk_from, disk_len = line:match("@@@* %-(%d+),?(%d*) .* %+(%d+),?(%d*) @@@*")
171+
index_from, index_len, disk_from, disk_len = line:match("^@@@* %-(%d+),?(%d*) .* %+(%d+),?(%d*) @@@*")
172172
else
173173
-- Normal diff header
174-
index_from, index_len, disk_from, disk_len = line:match("@@ %-(%d+),?(%d*) %+(%d+),?(%d*) @@")
174+
index_from, index_len, disk_from, disk_len = line:match("^@@ %-(%d+),?(%d*) %+(%d+),?(%d*) @@")
175175
end
176176

177177
if index_from then

0 commit comments

Comments
 (0)