Skip to content

Commit

Permalink
tiny refactor plus correct caret position after paste
Browse files Browse the repository at this point in the history
  • Loading branch information
charlieroberts committed Nov 28, 2024
1 parent f568b47 commit c5df428
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion bitty.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,9 @@ let bitty = window.bitty = {
// new position is:
// current position + (text length - line breaks)
let pos = caret()
pos += text.length - text.split('\n').length
// subtract one from length as last line won't actually contain line break
const lineBreakCount = text.split('\n').length - 1
pos += text.length - lineBreakCount

const shouldRemoveBlank = (
e.target.innerText === ''
Expand Down

0 comments on commit c5df428

Please sign in to comment.