-
Notifications
You must be signed in to change notification settings - Fork 194
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/Replace Overlay: highlight regex matches toggle #2679
Comments
I agree that this would be quite helpful to test regular expressions. The proposal has some overlap with: That one proposes to mark occurrences of a search string inside the document while typing. When this is also applied to regex searches (as it should be by default) and if it is also limited to the selected region (in case such a region is defined), it should cover this proposal completely, if I understand it correctly. Note that we merged a PR last week, which also partly covers this proposal: Search-as-you-type is now also applied in regex mode, so you can already use this to test a regex, but it will only give you a single match and not all matches in the selected region. But is of course also restricted to the selected region. |
+1 |
@HeikoKlare I updated to the latest build and I can see the change, it's certainly better. Apart from finding only the first search result, I found it odd that the highlight is actually a selection, so if I leave the Find/Replace focus my typing replaces the selection. I would have thought a "passive" highlight like Mark Occurrences would be more apt. Is there a reason to use selection? |
Considering the use case in an isolated way, I agree that one might argue for just highlighting a result instead of selecting it. In addition, the current behavioral consistency of the different modes mentioned above does not require the code to distinguish between different modes but mostly handles everything in the same way. Having regex mode behave different than other search modes would lead to additional implementation efforts and complexity in the code. |
I didn't notice that in the new Find/Replace there is a search-as-you-type implemented already for plain text. Since that is the case, the selection is fine. I was just not sure what the benefit of selection is when you have the option to replace that text with the Replace function. |
I see. The search-as-you-type just performs an ordinary selection, line when performing an explicit find operation (via the find foward/backward buttons). This is even a prerequisite for performing a replace operation. If there was no preceding find operation (including the selection of the match), you cannot execute a replace operation. This behavior is now also consistent to other tools (like VS Code and IntelliJ), which also have search-as-you-type enabled by default, that search performs selections, which are preserved when leaving the find UI, and the operate in the same way for normal and regex search. So users should experience quite similar behavior in different tools, allowing to use the same workflows without adapting to the tool they are using. |
When writing a regex in the Find field, it's useful to see the matches in the selected region (or the whole file if no region is selected) in real-time, much like ctrl+F works in browsers. This avoids repeatedly clicking on Find to see if the regex works as intended. Because for large files this can be costly, it should be enabled via a toggle. Matched regions can be indicated with a background highlight, just like Toggle Mark Occurrences works.
This is also relevant for the "old" Find/Replace dialog.
The text was updated successfully, but these errors were encountered: