readline: align delete-word-right span with word-right - #65180
Open
arhxam wants to merge 1 commit into
Open
Conversation
`[kDeleteWordRight]()` matched the text after the cursor with `/^(?:\s+|\W+|\w+)\s*/`, but its three sibling word-motion handlers (`kWordLeft`, `kWordRight`, `kDeleteWordLeft`) use `[^\w\s]+` for the symbol run. `\W` also matches whitespace, so delete-word-right (Meta+d or Ctrl+Delete) removed a different span than word-right (Meta+f) traverses whenever the text ahead was punctuation, whitespace, then more punctuation: for `-> => x` at column 0, word-right advances over `-> ` while delete-word-right deleted `-> => `. Use `[^\w\s]+` so the pattern is identical to `kWordRight` and the two operations always cover the same span. Signed-off-by: Arham Wani <arhamwani765@gmail.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.
Description
[kDeleteWordRight]()inlib/internal/readline/interface.jsmatched thetext after the cursor with
/^(?:\s+|\W+|\w+)\s*/. Its three siblingword-motion handlers all use
[^\w\s]+(a run of punctuation, excludingwhitespace) for the symbol-run alternative:
[kWordLeft]—/^\s*(?:[^\w\s]+|\w+)?/[kWordRight]—/^(?:\s+|[^\w\s]+|\w+)\s*/[kDeleteWordLeft]—/^\s*(?:[^\w\s]+|\w+)?/\Walso matches whitespace, so delete-word-right (Meta+d,Ctrl+Delete, Meta+Delete) removes a different span
than word-right (Meta+f, Ctrl+Right) traverses
whenever the text ahead of the cursor is punctuation, then whitespace,
then more punctuation.
Reproduction (built from this branch's parent,
terminal: true):Forward-word and kill-word are expected to cover the same span (as they
do in bash / GNU readline / emacs), and the other three handlers already
agree with each other. This aligns
[kDeleteWordRight]with[kWordRight]by using[^\w\s]+.Verification
main; the new regression testfails on the unpatched source (
actual: 'x',expected: '=> x') andpasses with the fix.
test-readline-interface.jsandtest-readline-promises-interface.js(covering all three key bindings).test/parallel/test-readline*.jssuite (21 files): all pass. Theexisting word-only cases are unaffected (both regexes agree on
\w).