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--? endassert(from.start_line == to.start_line)for i=from.end_line,from.start_line,-1 dotable.remove(lines, i)endassert(#to.lines == to.end_line-to.start_line+1)for i=1,#to.lines dotable.insert(lines, to.start_line+i-1, to.lines[i])endend
function minmax(a, b)return math.min(a,b), math.max(a,b)end
endfunction test_zzz_undo_load_test()print('\n\nTesting a 10KB file')-- create a large list of lineslocal lines = {}-- 10k characters, hundred lines, 2k wordsfor i=1,100 dolocal line = ''for c=1,20 doline = line..'abcd 'endendLines = load_array(lines)-- perform 1000 mutationsprint('are the dots printing quickly and without any pauses?')for i=1,1000 doif i%50 == 0 thenApp.run_after_keychord('return')elseApp.run_after_textinput('a')endif i%10 == 0 thenio.write(i)io.write(' ')io.flush()endend
if src.lines thenLines = 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--? endend
patch(Lines, event.before, event.after)
* Undo is extremely inefficient in space. While this app is extremely unlikelyto lose the current state of a file at any moment, undo history is volatileand should be considered unstable.
* Undo/redo can be sluggish in large files. If things get sluggish, killingthe process can lose data.