base: Fix broken move logic

Sometime I wonder WTF I was on when I wrote some parts or Radical...

I guess I can call it university stress...

Note that this will probably cause a bunch of regressions because
some other code expected the garbage I was creating.
This commit is contained in:
Emmanuel Lepage Vallee 2016-08-22 01:39:34 -04:00
parent 0e00d45cd4
commit e29771fa48
1 changed files with 8 additions and 14 deletions

View File

@ -558,21 +558,15 @@ local function new(args)
break break
end end
end end
if idx1 then if idx1 and idx ~= idx1 then
-- if idx < idx1 then table.remove(internal.items,idx1)
-- idx = idx + 1 table.insert(internal.items,idx, item)
-- end
if idx1 > #internal.items + 1 then for i=math.min(idx,idx1), idx1 > idx and idx1 or #internal.items do
idx1 = #internal.items + 1 internal.items[i].index = i
end
if idx ~= idx1 then
table.insert(internal.items,idx1,table.remove(internal.items,idx))
item.index = idx
data:emit_signal("item::moved",item,idx,idx1)
for i=idx,idx1 do
internal.items[i].index = i
end
end end
data:emit_signal("item::moved",item,idx,idx1)
end end
end end