delete some seemingly redundant code
We're patching line_cache and then immediately clearing it using Text.redraw_all.
This commit is contained in:
parent
5a74b6938e
commit
c064f0a97d
1
edit.lua
1
edit.lua
|
@ -440,7 +440,6 @@ function edit.keychord_press(State, chord, key)
|
|||
State.cursor1 = deepcopy(src.cursor)
|
||||
State.selection1 = deepcopy(src.selection)
|
||||
patch(State.lines, event.after, event.before)
|
||||
patch_placeholders(State.line_cache, event.after, event.before)
|
||||
-- invalidate various cached bits of lines
|
||||
State.lines.current_drawing = nil
|
||||
Text.redraw_all(State) -- if we're scrolling, reclaim all line caches to avoid memory leaks
|
||||
|
|
|
@ -441,7 +441,6 @@ function edit.keychord_press(State, chord, key)
|
|||
State.cursor1 = deepcopy(src.cursor)
|
||||
State.selection1 = deepcopy(src.selection)
|
||||
patch(State.lines, event.after, event.before)
|
||||
patch_placeholders(State.line_cache, event.after, event.before)
|
||||
-- invalidate various cached bits of lines
|
||||
State.lines.current_drawing = nil
|
||||
Text.redraw_all(State) -- if we're scrolling, reclaim all line caches to avoid memory leaks
|
||||
|
|
|
@ -81,17 +81,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
|
||||
|
|
11
undo.lua
11
undo.lua
|
@ -81,17 +81,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
|
||||
|
|
Loading…
Reference in New Issue