Search code examples
phpstorm

PhpStorm search not showing in results (that I know is there)


I've experienced in my search results (CMD Shift f) a couple of times, that I search for at string that I know is in my project - and then PhpStorm doesn't show me.

Like this one here:

Prev is missing

It feels a bit creepy, that I can't 'trust' my search to find this.

Solution attempt 1 - Narrow search

If I search only in the screens-directory, then it can find it:

Prev is there

... but what is super-weird is, that if I then widen the search, by simply removing screens, then I does not appear:

Prev is missing (again)

I went thoroughly through the whole list - and FinanceSingleTermScreen is not there.

Solution attempt 2 - Consider scopes

Maybe it's because there are simply so many files for it to search in. But it's quite annoying if I have to setup scopes for all projects, to start trusting my search again.

Solution attempt 3 - Reindex project

If I mark my app-folder at click CMD Option y (File >> Reload all from disk), to make sure it's not some memory thing.

But it doesn't do a difference.

Solution attempt 4: Close project and open it again

Didn't do anything.

Solution attempt 5: Change search string

I tried searching for >Prev instead of Prev, and then it shows up!!

Prev works

And here it is, if I remove the >:

Prev no works

... and I have went thoroughly through the search results of that last image. It's not there.

Solution attempt 6: Fiddle with filters

Obviously there are many options there.
I tried a bunch, but it didn't lead to anything.


Untried attempts

  • File >> Invalidate caches: It just seems extensive and shouldn't be necessary (I hope).

Solution

  • Accordingly to your screenshots it actually works correctly.

    You see, this "Find in Files" popup... it is more like a preview (very advanced one where you can edit the text right there... but still). It searches as fast as possible in multiple threads/files at the same time so the order and files searched can be different each time you search if you have many files with matched text.

    The key info is shown on this part of your screenshot:

    112+ matches in 28+ files

    enter image description here

    This means that you see only TOP 100 results (in a random order, see the note above).

    It is even possible (although it's very rare) to see that all 100+ results are from a single file (while you may have 100 more files with such a popular keyword). For example: try searching for class in a project where jQuery file is present (it has a lot of matches for that keyword).

    To see ALL matches just hit the button at the bottom right ("Open in Find Window") and the IDE will open a toolwindow with ALL search results (it will pause at around 1,000 results and ask if it should continue searching). The preview area / editing the file right there is also possible just like in the popup, just enable it.

    enter image description here

    To limit the searched files you can use the File mask field (top right corner), a Scope or Directory (e.g. only opened files / certain folder etc), or more precise search term (like you did with >Prev).