Maintenance: CommandBuilder - Fix isRegisterPending not considered in isEmpty, clone, equals, hashCode#1595
Open
claude[bot] wants to merge 1 commit intomasterfrom
Open
Conversation
…gisterPending The `isRegisterPending` field was not considered in several methods of `CommandBuilder`, causing subtle bugs: - `isEmpty` returned `true` while waiting for a register character (after typing `"`), which caused `EditorResetConsumer` to treat the partially-built command as if no command was in progress. This could trigger an incorrect error indicator (beep) when pressing `<Esc>` to cancel register selection in Normal mode, instead of silently resetting. - `clone()` did not copy `isRegisterPending`, meaning a cloned builder would lose pending register state. This is a latent bug affecting the unused `AsyncKeyProcessBuilder`. - `equals()` and `hashCode()` did not include `isRegisterPending`, so two builders differing only in pending-register state were considered equal, which is incorrect. Add a regression test that verifies `isEmpty` returns `false` while a register selection is pending, and `true` after cancelling with Escape. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Summary
vim-engine/.../command/CommandBuilder.ktisRegisterPendingwas missing fromisEmpty,clone(),equals(), andhashCode()isRegisterPendingto all four methods + regression testDetails
CommandBuildertracks whether the user has typed"to begin a register selection via theisRegisterPendingfield. However, this field was not included in several key methods:isEmptybug (observable)isEmptyreturnedtrueeven whileisRegisterPending = true(i.e., after the user typed"but before selecting a register character). This causedEditorResetConsumerto treat the partially-built command as empty when processing<Esc>, potentially triggering an incorrect error indicator (beep) when cancelling register selection in Normal mode. In Vim, pressing<Esc>to cancel a partially-built command should not produce an error.clone()bug (latent)clone()did not copyisRegisterPending, so a clonedCommandBuilderwould lose its pending-register state. This is a latent bug that would affectAsyncKeyProcessBuilderif it were ever used.equals()/hashCode()bug (correctness)Two
CommandBuilderinstances differing only inisRegisterPendingwere incorrectly considered equal.Test
Added a regression test in
CopyActionTestthat:"to start register selectioncommandBuilder.isEmpty == false(would fail before fix)<Esc>to cancelcommandBuilder.isEmpty == true