explicitly state when operations manage undo
This commit is contained in:
parent
95837a50f6
commit
2f2eeff1dd
4
edit.lua
4
edit.lua
|
@ -361,7 +361,7 @@ function edit.keychord_press(editor, chord, key)
|
|||
-- (we're not creating any ctrl-shift- or alt-shift- combinations using regular/printable keys)
|
||||
(not shift_down() or utf8.len(key) == 1) and
|
||||
chord ~= 'C-a' and chord ~= 'C-c' and chord ~= 'C-x' and chord ~= 'backspace' and chord ~= 'delete' and chord ~= 'C-z' and chord ~= 'C-y' and not is_cursor_movement(key) then
|
||||
Text.delete_selection(editor, editor.left, editor.right)
|
||||
Text.delete_selection_and_record_undo_event(editor)
|
||||
end
|
||||
if editor.search_term then
|
||||
if chord == 'escape' then
|
||||
|
@ -432,7 +432,7 @@ function edit.keychord_press(editor, chord, key)
|
|||
love.system.setClipboardText(s)
|
||||
end
|
||||
elseif chord == 'C-x' and cursor_on_screen then
|
||||
local s = Text.cut_selection(editor, editor.left, editor.right)
|
||||
local s = Text.cut_selection_and_record_undo_event(editor)
|
||||
if s then
|
||||
love.system.setClipboardText(s)
|
||||
end
|
||||
|
|
|
@ -5,14 +5,14 @@ function edit.mouse_loc(editor)
|
|||
return edit.to_loc(editor, mx, my)
|
||||
end
|
||||
|
||||
function Text.cut_selection(editor)
|
||||
function Text.cut_selection_and_record_undo_event(editor)
|
||||
if editor.selection1.line == nil then return end
|
||||
local result = Text.selection(editor)
|
||||
Text.delete_selection(editor)
|
||||
Text.delete_selection_and_record_undo_event(editor)
|
||||
return result
|
||||
end
|
||||
|
||||
function Text.delete_selection(editor)
|
||||
function Text.delete_selection_and_record_undo_event(editor)
|
||||
if editor.selection1.line == nil then return end
|
||||
local minl,maxl = minmax(editor.selection1.line, editor.cursor.line)
|
||||
local before = snapshot(editor, minl, maxl)
|
||||
|
|
4
text.lua
4
text.lua
|
@ -54,7 +54,7 @@ function Text.keychord_press(editor, chord)
|
|||
elseif chord == 'backspace' then
|
||||
if editor.cursor.mode == 'text' then
|
||||
if editor.selection1.line then
|
||||
Text.delete_selection(editor, editor.left, editor.right)
|
||||
Text.delete_selection_and_record_undo_event(editor)
|
||||
schedule_save(editor)
|
||||
return
|
||||
end
|
||||
|
@ -114,7 +114,7 @@ function Text.keychord_press(editor, chord)
|
|||
else
|
||||
-- cursor in text line
|
||||
if editor.selection1.line then
|
||||
Text.delete_selection(editor, editor.left, editor.right)
|
||||
Text.delete_selection_and_record_undo_event(editor)
|
||||
schedule_save(editor)
|
||||
return
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue