-
-
Notifications
You must be signed in to change notification settings - Fork 140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(find-and-replace) (whole word selection) Allow non-word to non-word boundaries #987
base: master
Are you sure you want to change the base?
Conversation
Ooh. This looks promising, but I'd love to see some new specs so we can figure out exactly what this will and won't do. |
Also: Chrome has supported lookbehinds in regular expressions since version 62, so we could try that instead. |
the non-capturing group still selects, apparently
There's no testing for whether it works at the start or end of a file now that I think about it Sanity check: (https://devina.io/redos-checker) |
Note to self, for faster further investigation: errors:
The last 4 are easy to fix, but I'm very concerned about the first two. The result changed from an array to an object, whose match starts at 0? So the first thing I need to do is actually understand what the code is doing |
Apparently, the word boundary And importantly, a word boundary can be of either the form So what this pr is trying to do, is allow |
Actually, I think the purpose of "whole word" search is for there to specifically be non-word characters surrounding the selection, i.e. the selection itself forms a "word" (which may or may not include non-word characters). Therefore, simulating This is kinda breaking so feedback from anyone who uses this option would be nice |
The (1) test failures now are equally baffling...
Edit: Oh, I forgot to set the cursor position and to run the command for the first test |
Identify the Bug
#986
Description of the Change
What is "whole word"?
There's a feature in find-and-replace called "whole word". For example, ctrl+f
i
will match every singlei
in the code:But if you turn on "whole word", it only matches the
i
that form a whole word. Since thei
infunction
is only part of a word, not a whole word, turning on "whole word" will now select something more useful:Bug
How is whole-word detected? Basically we match a "word boundary": a transition from a non-word to word character, or from a word to non-word character.
But what if the selection is say,
$wha
?Clearly,
$wha
is a whole word. Except it's not, because at the start we are going from non-word (space) to non-word (dollar), i.e. not a word boundary.Change fix
Allow (non-word character --> non-word character) boundaries
Alternate Designs
Possible Drawbacks
"whole word" might still be inaccurate in cases like
$
in$$
; might break people's workflowVerification Process
Release Notes
(find-and-replace) (whole word selection) Allow non-word to non-word boundaries