diff options
Diffstat (limited to 'undo.lua')
-rw-r--r-- | undo.lua | 23 |
1 files changed, 1 insertions, 22 deletions
diff --git a/undo.lua b/undo.lua index e5dea93..08b867c 100644 --- a/undo.lua +++ b/undo.lua @@ -50,23 +50,13 @@ function snapshot(State, s,e) screen_top=deepcopy(State.screen_top1), selection=deepcopy(State.selection1), cursor=deepcopy(State.cursor1), - current_drawing_mode=Drawing_mode, - previous_drawing_mode=State.previous_drawing_mode, lines={}, start_line=s, end_line=e, -- no filename; undo history is cleared when filename changes } - -- deep copy lines without cached stuff like text fragments for i=s,e do - local line = State.lines[i] - if line.mode == 'text' then - table.insert(event.lines, {mode='text', data=line.data}) -- I've forgotten: should we deepcopy(line.data)? - elseif line.mode == 'drawing' then - table.insert(event.lines, {mode='drawing', h=line.h, points=deepcopy(line.points), shapes=deepcopy(line.shapes), pending={}}) - else - assert(false, ('unknown line mode %s'):format(line.mode)) - end + table.insert(event.lines, deepcopy(State.lines[i])) end return event end @@ -89,17 +79,6 @@ function patch(lines, from, to) end end -function patch_placeholders(line_cache, from, to) - assert(from.start_line == to.start_line, 'failed to patch undo operation') - for i=from.end_line,from.start_line,-1 do - table.remove(line_cache, i) - end - assert(#to.lines == to.end_line-to.start_line+1, 'failed to patch undo operation') - for i=1,#to.lines do - table.insert(line_cache, to.start_line+i-1, {}) - end -end - -- https://stackoverflow.com/questions/640642/how-do-you-copy-a-lua-table-by-value/26367080#26367080 function deepcopy(obj, seen) if type(obj) ~= 'table' then return obj end |