prompt-toolkit / prompt-toolkit/python-prompt-toolkit
`on_cursor_position_changed` events don't fire on line-select-mode entry
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 10.6k
- Forks
- 815
- PR merge metrics
- No merged PRs in 30d
Description
I'm hooking into cursor events and using them to determine what is currently selected, like so:
def update(event):
if event.selection_state:
selected_from = min(
event._Buffer__cursor_position,
event.selection_state.original_cursor_position,
)
selected_to = max(
event._Buffer__cursor_position,
event.selection_state.original_cursor_position,
)
...
buffer = Buffer(on_text_changed=update, on_cursor_position_changed=update)
This works well in visual mode but in visual line mode it doesn't capture the selection (because in this mode the selection appears to be decoupled from cursor position).
Is there a good way to get the selection bounds in this case?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Buffer callbacks shown in the issue, especially on_cursor_position_changed and selection_state, and trace how visual line mode updates selection independently of cursor position. Check the relevant selection and event-handling code for an existing regression test. Done means selection bounds are observable when entering line-select mode without breaking visual mode behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 42/100