Merge pull request #376 from adamharrison/clipboard-fix
Added in a hash check to the system clipboard.
This commit is contained in:
commit
37dcc4725f
|
@ -67,6 +67,7 @@ local function cut_or_copy(delete)
|
||||||
doc().cursor_clipboard[idx] = ""
|
doc().cursor_clipboard[idx] = ""
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
doc().cursor_clipboard["full"] = full_text
|
||||||
system.set_clipboard(full_text)
|
system.set_clipboard(full_text)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -99,8 +100,13 @@ local commands = {
|
||||||
end,
|
end,
|
||||||
|
|
||||||
["doc:paste"] = function()
|
["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
|
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)
|
doc():text_input(value:gsub("\r", ""), idx)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
|
@ -173,10 +173,12 @@ function Doc:merge_cursors(idx)
|
||||||
if self.selections[i] == self.selections[j] and
|
if self.selections[i] == self.selections[j] and
|
||||||
self.selections[i+1] == self.selections[j+1] then
|
self.selections[i+1] == self.selections[j+1] then
|
||||||
common.splice(self.selections, i, 4)
|
common.splice(self.selections, i, 4)
|
||||||
|
common.splice(self.cursor_clipboard, i, 1)
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if #self.selections <= 4 then self.cursor_clipboard = {} end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function selection_iterator(invariant, idx)
|
local function selection_iterator(invariant, idx)
|
||||||
|
|
Loading…
Reference in New Issue