Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Support multiple selections when "Only In Selection" option is enabled #1088
Description of the Change
Previously, the "Only In Selection" option only supported the most recently created selection rather than all selections. This led to particularly bad results when clicking "Find All" and then "Replace All", because "Find All" would select all of the results, creating multiple selections. Then the search markers would be re-created, but only for the last of the selections. When you then clicked "Replace All", only the last of the selected original results would be replaced due to this being the only marker. In this PR, we now loop over all selections when populating the search markers.
In this PR, I'm looping over the selected ranges within the find and replace package and calling
To make sure performance was at least reasonable, I recorded a profile of changing the search pattern with 7849 selections. We only spend about 26ms calling into
That seems like acceptable performance, especially for a rather rare case.
None that I can think of.
In testing this, I also experimented with the "Find Next" and "Find Previous" commands, which select the next and previous result respectively. When "Only In Selection" is enabled, these commands become pretty much worthless, because obviously only one result is selected. Maybe it would make more sense to ignore the "Only In Selection" option for the purpose of these commands, but since doing so would involve a big change and we haven't gotten complaints about that use case, I'm going to avoid it for now.