Skip to content

Commit

Permalink
Merge pull request #5 from bjornbm/master
Browse files Browse the repository at this point in the history
Fix undo of multiline insertion.
  • Loading branch information
philanc authored Apr 27, 2023
2 parents eca17b3 + 841159b commit 8c4bc0f
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 8c4bc0f

Please sign in to comment.