Repository navigation
[find-and-replace] Prevent addition of project resultsâĶ - #1380
Merged
confused-Techie merged 1 commit intoNov 22, 2025
Merged
Conversation
âĶfrom editors whose paths are not matched by the current path inclusions.
Contributor
Author
|
@confused-Techie, I opened this PR against
|
confused-Techie
approved these changes
Nov 22, 2025
confused-Techie
left a comment
Member
There was a problem hiding this comment.
@savetheclocktower Thanks for getting to this so quickly! This does indeed fix my original test case and we should go ahead and merge it, awesome work!
savetheclocktower
deleted the
find-and-replace-editor-sneaks-into-results
branch
November 22, 2025 02:05
This was referenced Feb 15, 2026
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.
âĶfrom editors whose paths are not matched by the current path inclusions.
Fixes #1379.
The
find-and-replacepackage wants to do a good job. It wants to ensure that your project-wide search results are a real-time reflection of the state of the workspace.So when you search for
devinsite/templates, it doesn't just do a one-off search. It also listens for changes to the active editor and keeps its results current in the results view. Ifsites/templates/foo.ejsdidn't contain the stringdevwhen you did the searchâĶ but then you edited the file and added the worddevsomewhereâĶ it will pop up in the results!This is handy except when it shouldn't actually be there. The initial search â the one that happened in the background using either
ripgrepor the other strategy (forget what it is) â took path inclusions/exclusions into account. The incremental re-search â the one that happens when you make changes to the active buffer â appears not to consider those path patterns. So that's what we need to fix.This is related to #1298. (I thought it might've been caused by #1298, but I can't figure out how, so I think this has just always been an issue.) In both cases, we're bypassing the efficient project-wide search (with a dedicated tool) to perform a manual single-buffer search. In both cases, the bypass process ended up also bypassing any path patterns that may have been specified, causing a bug.
We had to introduce some new logic to fix #1298, and luckily we're able to reuse it here. Since
atom.workspacecan already take our path pattern syntax and convert it intominimatchobjects, all we need to do is expose the ability to ask âhypothetically, would path X be excluded by path pattern list Y?â from thefind-and-replacepackage. I've added a newatom.workspace.filePathMatchesPatternsmethod to do just that.The new method has specs to prove it works as intended.
Only a little new code is added in
find-and-replaceitself: before we add a set of results to the project-search results list, we ensure that the file path it came from matches our current path inclusions/exclusions list. In many cases, this checking is redundant, sinceripgrep(or the other thing) will already be ignoring those pathsâĶ but that's OK.