Skip to content

Commit 640cbab

Browse files
committed
Corrected how hunk header add and remove starting position are calculated.
1 parent d679b3c commit 640cbab

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

demo/xtra/DIFF.LUA

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
#!/usr/bin/env lua
1+
#!/usr/bin/env lua
22

33
local function diff_u(fn1,fn2)
44
local function open(fn) local f, e = io.open(fn) if not f then print(e) os.exit(1) end return f end
55
local f1, f2, pre, add, del, p1, p2, x, y, h, l1, l2 = open(fn1), open(fn2), {}, {}, {}, 0, 0, 0, 0
66
local buf = {add = 0, del = 0, line = {}}
77
local function flush_pre()
88
if not h then print("--- " .. fn1 .. "\n+++ " .. fn2) h = true end
9-
for _, v in ipairs(pre) do table.insert(buf.line, " " .. v) end
10-
buf.ls, buf.rs, pre = x, y, {}
9+
if #pre > 0 then
10+
for _, v in ipairs(pre) do table.insert(buf.line, " " .. v) end
11+
buf.ls, buf.rs = x - #pre, y - #pre
12+
end
13+
pre = {}
1114
end
1215
local function flush_hunk()
1316
for _, v in ipairs(del) do table.insert(buf.line, "-" .. v) end

0 commit comments

Comments
 (0)