Skip to content

Conversation

@masmu
Copy link
Contributor

@masmu masmu commented Feb 2, 2026

Previously, Delete(Sub)WordLeft/Right commands would delete the word or subword adjacent to the cursor, even if the user had actively selected a range of text.

This PR modifies DeleteWordRight, DeleteWordLeft, DeleteSubWordRight and DeleteSubWordLeft.
These functions now check h.Cursor.HasSelection().
- If a selection exists, they delete the selected text.
- If a selection does not exist, they proceed with the original behavior (select word/subword and delete it).

This ensures micro behaves consistently with other modern text editors. When a user explicitly selects a range of text, a delete command should remove that specific range, rather than modifying the buffer based solely on cursor position relative to word boundaries.

Fixes #3984

Previously, Delete(Sub)WordLeft/Right commands would delete the word or subword adjacent to the cursor, even if the user had actively selected a range of text.

This commit modifies `DeleteWordRight`, `DeleteWordLeft`, `DeleteSubWordRight` and `DeleteSubWordLeft`. These actions now check if a selection exists:
- If yes, the existing selection is deleted.
- If no, the previous behavior (select word + delete) is executed.

This aligns the behavior with standard text editing conventions.

Fixes micro-editor#3984
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Delete(Sub)?Word does not respect selection ranges

1 participant