Merge pull request #376 from adamharrison/clipboard-fix

Added in a hash check to the system clipboard.
This commit is contained in:
Adam 2021-08-12 15:30:50 -04:00 committed by GitHub
commit 37dcc4725f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -67,6 +67,7 @@ local function cut_or_copy(delete)
doc().cursor_clipboard[idx] = ""
end
end
doc().cursor_clipboard["full"] = full_text
system.set_clipboard(full_text)
end
@ -99,8 +100,13 @@ local commands = {
end,
["doc:paste"] = function()
local clipboard = system.get_clipboard()
-- If the clipboard has changed since our last look, use that instead
if doc().cursor_clipboard["full"] ~= clipboard then
doc().cursor_clipboard = {}
end
for idx, line1, col1, line2, col2 in doc():get_selections() do
local value = doc().cursor_clipboard[idx] or system.get_clipboard()
local value = doc().cursor_clipboard[idx] or clipboard
doc():text_input(value:gsub("\r", ""), idx)
end
end,

View File

@ -173,10 +173,12 @@ function Doc:merge_cursors(idx)
if self.selections[i] == self.selections[j] and
self.selections[i+1] == self.selections[j+1] then
common.splice(self.selections, i, 4)
common.splice(self.cursor_clipboard, i, 1)
break
end
end
end
if #self.selections <= 4 then self.cursor_clipboard = {} end
end
local function selection_iterator(invariant, idx)