Skip to content

Commit

Permalink
When wiping last line, don't add newline.
Browse files Browse the repository at this point in the history
The fixes a weirdness where wiping the last line is not undone by a
single ^Z, due to the newline insertion being a separate event in the
undo action list (b.ual). Thus, to get back to the state prior to a wipe
of the last line, two undos were required.

With this modification, the behavior when wiping the last line is
slightly modified. Specifically, the wipe does not include a newline at
the end (after all, there was no newline to wipe in the first place). As
a consequence, when yanking the wiped line, there we will also be no
newline at the end of the insert.

For precedence, this is consistent with the emacs ^K on the last line
(even if wipe behavior is not in general identical to ^K).
  • Loading branch information
bjornbm committed Apr 27, 2023
1 parent 841159b commit a536e8e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions ple.lua
Original file line number Diff line number Diff line change
Expand Up @@ -678,12 +678,14 @@ function e.wipe(b, nokeep)
-- (default false)
if not b.si then
msg("No selection.")
if b:atlast() then -- add an empty line at end
e.goeot(b); e.nl(b); e.goup(b)
end
e.gohome(b)
local xi, xj
xi, xj = b.ci+1, 0
if b:atlast() then -- don't remove the newline
xi, xj = b:eol()
xj = xj + 1 -- include last character on line
else
xi, xj = b.ci+1, 0
end
if not nokeep then editor.kll = b:getlines(xi, xj) end
b:bufdel(xi, xj)
return
Expand Down

0 comments on commit a536e8e

Please sign in to comment.