From 7046bfca24a821ebfcf5eb3664be49614abdc084 Mon Sep 17 00:00:00 2001 From: rxi Date: Sun, 12 Apr 2020 11:22:06 +0100 Subject: [PATCH] Made cut/copy no-op if there is no selection --- data/core/commands/doc.lua | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/data/core/commands/doc.lua b/data/core/commands/doc.lua index 8a9aedd..cac62f6 100644 --- a/data/core/commands/doc.lua +++ b/data/core/commands/doc.lua @@ -70,14 +70,18 @@ local commands = { end, ["doc:cut"] = function() - local text = doc():get_text(doc():get_selection()) - system.set_clipboard(text) - doc():delete_to(0) + if doc():has_selection() then + local text = doc():get_text(doc():get_selection()) + system.set_clipboard(text) + doc():delete_to(0) + end end, ["doc:copy"] = function() - local text = doc():get_text(doc():get_selection()) - system.set_clipboard(text) + if doc():has_selection() then + local text = doc():get_text(doc():get_selection()) + system.set_clipboard(text) + end end, ["doc:paste"] = function()