mirror of
https://github.com/anomalyco/opentui.git
synced 2026-04-25 13:06:00 +03:00
[GH-ISSUE #652] Add onEncounter and onDeletion hooks for virtual extmarks #177
Labels
No labels
bug
core
documentation
feature
good first issue
help wanted
pull-request
question
react
solid
tmux
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/opentui#177
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @jorgeraad on GitHub (Feb 9, 2026).
Original GitHub issue: https://github.com/anomalyco/opentui/issues/652
Summary
Virtual extmarks currently hard-code cursor skipping and whole-range deletion. Consumers have no way to customize what happens when the cursor hits a virtual extmark or when the user tries to delete one. This adds per-extmark
onEncounterandonDeletioncallbacks toExtmarkOptions, enabling patterns like "select then act" — where the first arrow press stops at the extmark and a second press skips past it.Motivation: opencode#8501 — pasted text summarized into virtual extmarks needs a way to expand inline. Without hooks, consumers must intercept keyboard events before the controller, duplicate private adjacency-detection logic, and fight with the wrapped
setCursorByOffset. Hooks at the controller level are the clean solution.API
Behavior
Extmarkinterface), following the existingmetadatapattern — excluded from undo/redo snapshotsScope
In scope:
onEncounterhooks wired into all 5 wrapped cursor methods (moveCursorLeft,moveCursorRight,moveUpVisual,moveDownVisual,setCursorByOffset)onDeletionhooks wired intodeleteCharBackwardanddeleteCharcreate(),delete(), andclear()Out of scope:
styleIdin place)