Reverted hash changes; simply copy entire clipboard.

This commit is contained in:
Adam Harrison
2021-08-11 18:14:46 -04:00
parent 255c45b30b
commit aa4d91a03f
4 changed files with 21 additions and 34 deletions
+13 -16
View File
@@ -53,18 +53,6 @@ local function save(filename)
core.log("Saved \"%s\"", saved_filename)
end
local function split_cursor(direction)
local new_cursors = {}
for _, line1, col1 in doc():get_selections() do
if line1 > 1 and line1 < #doc().lines then
table.insert(new_cursors, { line1 + direction, col1 })
end
end
for i,v in ipairs(new_cursors) do doc():add_selection(v[1], v[2]) end
core.blink_reset()
end
local function cut_or_copy(delete)
local full_text = ""
for idx, line1, col1, line2, col2 in doc():get_selections() do
@@ -79,12 +67,21 @@ local function cut_or_copy(delete)
doc().cursor_clipboard[idx] = ""
end
end
if #doc().cursor_clipboard > 1 then
doc().cursor_clipboard["hash"] = system.hash(full_text)
end
doc().cursor_clipboard["full"] = full_text
system.set_clipboard(full_text)
end
local function split_cursor(direction)
local new_cursors = {}
for _, line1, col1 in doc():get_selections() do
if line1 > 1 and line1 < #doc().lines then
table.insert(new_cursors, { line1 + direction, col1 })
end
end
for i,v in ipairs(new_cursors) do doc():add_selection(v[1], v[2]) end
core.blink_reset()
end
local commands = {
["doc:undo"] = function()
doc():undo()
@@ -105,7 +102,7 @@ local commands = {
["doc:paste"] = function()
local clipboard = system.get_clipboard()
-- If the clipboard has changed since our last look, use that instead
if doc().cursor_clipboard["hash"] ~= system.hash(clipboard) then
if doc().cursor_clipboard["full"] ~= clipboard then
doc().cursor_clipboard = {}
end
for idx, line1, col1, line2, col2 in doc():get_selections() do