Skip to content

Commit

Permalink
Fix undo of multiline insertion.
Browse files Browse the repository at this point in the history
Problem fixed: Insert a newline at cj>1. Undo (^Z). The undo operation
removes cj-1 characters following the point of the insertion.
  • Loading branch information
bjornbm committed Apr 27, 2023
1 parent eca17b3 commit 841159b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion buffer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 841159b

Please sign in to comment.