Skip to content

Commit

Permalink
fix: only show the cursor when selection is empty
Browse files Browse the repository at this point in the history
This matches the behavior of the native browser cursor.
  • Loading branch information
ocavue committed Nov 22, 2022
1 parent 66e56a9 commit e38ea46
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export function createVirtualCursor(): Plugin {
|| event.isComposing
|| !['ArrowLeft', 'ArrowRight'].includes(event.key)
|| !isTextSelection(selection)
|| !selection.$cursor
|| !selection.empty
)
return false

Expand Down Expand Up @@ -101,7 +101,11 @@ export function createVirtualCursor(): Plugin {
},

decorations: (state) => {
if (!_cursor || !isTextSelection(state.selection))
if (
!_cursor
|| !isTextSelection(state.selection)
|| !state.selection.empty
)
return

return DecorationSet.create(state.doc, [
Expand Down

0 comments on commit e38ea46

Please # to comment.