Now the bottleneck shifts to applying undo/redo in large files. But things should be snappy if you don't use the sluggish feature.
VJ77YABHVJZWJKLHAGIPC562GYM73AUGRLCP4JLKP5JPWPT2RIHAC
4QQBMWLLIA42YP6FBFC445ABQH62RRJBL5KKILTERJALPOJCYK4QC
N6V6UJ3P4EAGM7OLPAW7VBCDNQQHCWIK7GAEDB53LTL6XPR5YUKAC
SQLVYKVJ5O4UMKTT56LMFPDQX66SZJJ7FZSFEN5MTWPXXWL7X3WQC
73OCE2MCBJJZZMN2KYPJTBOUCKBZAOQ2QIAMTGCNOOJ2AJAXFT2AC
DHI6IJCNSTHGED67T6H5X6Y636C7PIDGIJD32HBEKLT5WIMRS5MAC
BULPIBEGL7TMK6CVIE7IS7WGAHGOSUJBGJSFQK542MOWGHP2ADQQC
G6OYAYHUSMSPKLRW52LQDAF4NBHFPWY3GZAHZZDLJY2ZL6NLTNEQC
2ZYV7D3W2HPQW2HYB7XDPM4T7KEWPUFPZ77BDLCCDSCLRPJFK6PQC
SLLR6KKIAAJJPODFJLHXNG7Z22C3QUBGEIESWOFOGQVHYJJQ6VSQC
2RXZ3PGOTTZ6M4R372JXIKPLBQKPVBMAXNPIEO2HZDN4EMYW4GNAC
XNFTJHC4QSHNSIWNN7K6QZEZ37GTQYKHS4EPNSVPQCUSWREROGIQC
PHFWIFYKFOGVX7CEAMGJ3FDY6LL5QSZ7T7CTCZ66WMNXV6C242FAC
CG3264MMJTTSCJWUA2EMTBOPTDB2NZIJ7XICKHWUTZ4UWLFP7POAC
FS2ITYYHBLFT66YUC3ENPFYI2HOYHOVEPQIN7NQR6KF5MEK4NKZAC
IDGP4BJZTKAD6ZO4RLAWYVN6IFCMIM76G6HJGPTE27K4D6CDBUHQC
function patch(lines, from, to)
--? if #from.lines == 1 and #to.lines == 1 then
--? assert(from.start_line == from.end_line)
--? assert(to.start_line == to.end_line)
--? assert(from.start_line == to.start_line)
--? lines[from.start_line] = to.lines[1]
--? return
--? end
assert(from.start_line == to.start_line)
for i=from.end_line,from.start_line,-1 do
table.remove(lines, i)
end
assert(#to.lines == to.end_line-to.start_line+1)
for i=1,#to.lines do
table.insert(lines, to.start_line+i-1, to.lines[i])
end
end
function minmax(a, b)
return math.min(a,b), math.max(a,b)
end
end
function test_zzz_undo_load_test()
print('\n\nTesting a 10KB file')
-- create a large list of lines
local lines = {}
-- 10k characters, hundred lines, 2k words
for i=1,100 do
local line = ''
for c=1,20 do
line = line..'abcd '
end
end
Lines = load_array(lines)
-- perform 1000 mutations
print('are the dots printing quickly and without any pauses?')
for i=1,1000 do
if i%50 == 0 then
App.run_after_keychord('return')
else
App.run_after_textinput('a')
end
if i%10 == 0 then
io.write(i)
io.write(' ')
io.flush()
end
end
if src.lines then
Lines = deepcopy(src.lines)
--? for _,line in ipairs(Lines) do
--? if line.mode == 'drawing' then
--? print('restoring', line.points, 'with', #line.points, 'points')
--? print('restoring', line.shapes, 'with', #line.shapes, 'shapes')
--? end
--? end
end
patch(Lines, event.before, event.after)
* Undo is extremely inefficient in space. While this app is extremely unlikely
to lose the current state of a file at any moment, undo history is volatile
and should be considered unstable.
* Undo/redo can be sluggish in large files. If things get sluggish, killing
the process can lose data.