support undo of paste button
This commit is contained in:
parent
2ff2692bb4
commit
a3fdbaad6d
|
@ -1,7 +1,20 @@
|
|||
paste_button = function(x, y, r)
|
||||
return overflowable_button('paste', x, y, r,
|
||||
function()
|
||||
local state = Current_pane.editor_state
|
||||
-- initial state for recording undo operation
|
||||
local before_line = state.cursor1.line
|
||||
local before = snapshot(state, before_line)
|
||||
-- paste
|
||||
local s = App.get_clipboard()
|
||||
Text.insert_text(Current_pane.editor_state, s)
|
||||
Text.insert_text(state, s)
|
||||
-- record undo operation
|
||||
record_undo_event(state,
|
||||
{
|
||||
before=before,
|
||||
after=snapshot(
|
||||
state, before_line,
|
||||
state.cursor1.line)
|
||||
})
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue