Skip to content

Commit 15acbbb

Browse files
committed
Fixed 3 context lines being treated like the end of a hunk when the next line is contains a difference.
1 parent 640cbab commit 15acbbb

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

demo/xtra/DIFF.LUA

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,29 @@ local function diff_u(fn1,fn2)
3131
flush_hunk()
3232
if #pre >= 3 then table.remove(pre, 1) end
3333
if p1 > 0 or p2 > 0 then
34-
if p1 > 0 and p2 > 0 then table.insert(buf.line, " " .. l2) p1, p2 = p1 - 1, p2 - 1
35-
elseif p1 > 0 then table.insert(buf.line, " " .. l1) p1 = p1 - 1
36-
elseif p2 > 0 then table.insert(buf.line, " " .. l2) p2 = p2 - 1 end
34+
if p1 > 0 and p2 > 0 then
35+
if p1 > 1 or p2 > 1 then table.insert(buf.line, " " .. l2) end
36+
p1, p2 = p1 - 1, p2 - 1
37+
elseif p1 > 0 then
38+
if p1 > 1 then table.insert(buf.line, " " .. l1) end
39+
p1 = p1 - 1
40+
elseif p2 > 0 then
41+
if p2 > 1 then table.insert(buf.line, " " .. l2) end
42+
p2 = p2 - 1
43+
end
3744
if p1 == 0 or p2 == 0 then flush_buf() end
3845
else
3946
table.insert(pre, l2)
4047
end
4148
x, y, l1, l2 = x + 1, y + 1, f1:read("*l"), f2:read("*l")
4249
end
4350
local function right()
44-
flush_pre() p1 = 3
51+
flush_pre() p1 = 4
4552
table.insert(del, l1)
4653
l1 = f1:read("*l")
4754
end
4855
local function down()
49-
flush_pre() p2 = 3
56+
flush_pre() p2 = 4
5057
table.insert(add, l2)
5158
l2 = f2:read("*l")
5259
end

0 commit comments

Comments
 (0)