Skip to content

Commit ae149a6

Browse files
committed
Added length to compare match.
1 parent 6588b5a commit ae149a6

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

xtra/DIFF.LUA

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ local function diff_u(fn1,fn2)
1818
for x=1,h do
1919
for y=la,w do
2020
if cmp(x,y)then
21-
table.insert(m,{y=y,x=x})
21+
if #m>0 and m[#m].x+m[#m].l==x and m[#m].y+m[#m].l==y then
22+
m[#m].l=m[#m].l+1
23+
else
24+
table.insert(m,{y=y,x=x,l=1})
25+
end
2226
la=y
2327
break
2428
end
@@ -46,13 +50,13 @@ local function diff_u(fn1,fn2)
4650
j,u.n.l,u.e=j+1,u.n.l+1,0
4751
end
4852
if u then
49-
if u.e<4 and i<=h and j<=w then
53+
while u.e<4 and i<=h and j<=w do
5054
table.insert(u.l,pfl(" ",get(fn1,f1,i)))
51-
u.e,u.o.l,u.n.l=u.e+1,u.o.l+1,u.n.l+1
52-
else
53-
flush()
55+
i,j,u.e,u.o.l,u.n.l=i+1,j+1,u.e+1,u.o.l+1,u.n.l+1
5456
end
55-
end i,j=i+1,j+1
57+
flush()
58+
end
59+
i,j=p.x+p.l,p.y+p.l
5660
end
5761
local function nlc()if la then la=la:sub(-1)if la~='\n'and la~='\r'then table.insert(u.l,"\\ No newline at end of file")end end end
5862
while i<=h do init()la=get(fn1,f1,i,ps)table.insert(u.l,pfl("-",la))i,u.o.l,u.e=i+1,u.o.l+1,0 end nlc()

0 commit comments

Comments
 (0)