Repository navigation
Fix Delete(Sub)Word commands to respect active selection - #3987
Merged
Merged
Conversation
JoeKar
requested changes
Feb 7, 2026
masmu
force-pushed
the
fix/delete-word-selection
branch
from
February 9, 2026 14:20
403ea57 to
bb9fd3e
Compare
JoeKar
approved these changes
Feb 9, 2026
dmaluka
reviewed
Jul 16, 2026
Delete(Sub)WordLeft/Right deleted the word adjacent to the cursor even when the user had an active selection, so text outside the selection was deleted. These actions now delete the current selection when one exists, and only select a word/subword to delete when there is none. This makes the behavior predictable and matches standard text editing conventions. Fixes micro-editor#3984
Add a DeleteSelections action that deletes the selection of every cursor when any selection is active, and returns true so that chained actions stop. It is not a MultiAction because it iterates all cursors itself, which gives a single global check for active selections and keeps the outcome predictable in multi-cursor edits. The default keybindings are unchanged. Users can chain the action with the deletion action they prefer, for example `DeleteSelections|DeleteWordLeft`.
masmu
force-pushed
the
fix/delete-word-selection
branch
from
November 6, 2026 08:30
bb9fd3e to
4b92630
Compare
dmaluka
approved these changes
Nov 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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,DeleteSubWordRightandDeleteSubWordLeft.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
microbehaves 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