From 841159b26fa13e260e3f76b85749fe98f437de29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Buckwalter?= Date: Thu, 27 Apr 2023 08:29:43 +0200 Subject: [PATCH 1/2] Fix undo of multiline insertion. Problem fixed: Insert a newline at cj>1. Undo (^Z). The undo operation removes cj-1 characters following the point of the insertion. --- buffer.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/buffer.lua b/buffer.lua index ac41e2d..3fe5b74 100644 --- a/buffer.lua +++ b/buffer.lua @@ -334,7 +334,11 @@ function buffer.op_undo(b, sl) if sl.op == "del" then return b:bufins(sl, true) elseif sl.op == "ins" then - return b:bufdel(sl.ci+#sl-1, sl.cj+ulen(sl[#sl]), true) + if #sl == 1 then -- Insertion was limited to part of a single line + return b:bufdel(sl.ci+#sl-1, sl.cj+ulen(sl[#sl]), true) + else -- Insertion spanned multiple lines + return b:bufdel(sl.ci+#sl-1, ulen(sl[#sl]), true) + end else return nil, "unknown op" end From fd123ca2218aeb0e4bf9568f1b119c395678f6f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Buckwalter?= Date: Thu, 27 Apr 2023 15:14:57 +0200 Subject: [PATCH 2/2] Allow to cancel quitting with ^X. When quitting is blocked by unsaved files, allows to abort the quit by a starting a ^X key sequence, without first dismissing the "Quit?" question. The primary expected use is for the user to do ^X-^S, ^X-^C when realizing that their buffer wasn't saved. (Typing a 'n' or hitting return or enter before the ^X-^S may seem like a small step, but my own experience is that I forget and want to go straight to ^X-^s.) --- ple.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ple.lua b/ple.lua index 3a95d79..addd666 100644 --- a/ple.lua +++ b/ple.lua @@ -727,7 +727,12 @@ function e.exiteditor(b) end if anyunsaved then local ch = readchar( - "Some buffers not saved. Quit? ", "[YNQynq\r\n]") + "Some buffers not saved. Quit? ", "[YNQynq\r\n\24]") + if ch == "\24" then -- ^X + msg("^X") + e.prefix_ctlx(b) + return + end if ch ~= "y" and ch ~= "Y" then msg("aborted.") return