Find in Files keeps defaulting to Directory

It doesn't seem to remember what I last used, and I typically need it for In Project.

I'm not seeing an option to default to "last used" upon open.

I usually open it using the keyboard shortcut Cmd+Shift+F.

 

2
18 comments

Hi there,

A bit more context is needed here.

The thing is: if you invoke the shortcut when focus is in the Project View panel then "Directory" option (and corresponding path) will be pre-selected. But if it's invoked while the focus is in the Editor area then the last used scope/option is selected.

This is how it works for a few years now (works fine for me here on Windows 10; v2021.1.3).

 

1

OK when I test, that's how it's working; but I'm not in the Project panel anywhere near as often as the file tabs... so I'm not sure how it's changing contexts so often.

Maybe I'm using the Project panel more often than I think, so I'll pay more attention to that. I am learning some of these repos so maybe I'm using the Project panel more often than I'm used to.

0

I did a few simple experiments here and this is what I can say:

  • If you close Find in Files popup (using Esc) it will bring the focus back where it was at the moment of invocation (assuming you have used keyboard shortcut to call Find in Files and not mouse and main menu as when using a main menu some Scopes will not be available (e.g. Selected Files)). Next time you see such unexpected change -- check where the focus was using the above method.
  • Other tool windows that have references to a specific file may also change to Directory option. For example: Problems toolwindow -- if invoked from "Current File" tab it will change to Directory. If done the same from the Project Error tab it will remain as before.
    At the same time the Find Results toolwindow (the one that shows ALL found results -- when you use "Open in Find Window" button in Find in Files) does not produce such behaviour.
  • If you invoke Find in Path using shortcut while another file-related popup is opened (e.g. use "Navigate | File", enter some file name that is present in a few different folders) then once invoked Find in Files will have Directory option selected (and the path set to the focused file from that popup).

So yes, do your observations and try to spot your patterns.

BTW -- you can quickly focus the Editor from any tool window by pressing Esc (should be the default key in all keymaps). If not -- check  "Editor Actions | Focus Editor" action on Keymap screen.

 

P.S. Originally Find in Files (Find in Path back then) was always using Whole Project scope and not remembering the previous scope. You can check comments in https://youtrack.jetbrains.com/issue/IDEA-87037 for some more info if you wish.

0

OK so I found in one case, when the focus was last in the Project panel, if I select some text from one of the open files (as in, left-click to the left or right of a character then drag the mouse over text to select it), then open Find in Files using the keyboard shortcut, the selected scope will be Directory.

So selecting text that way in an open file tab will not change the focus to that tab :/ I rarely use Directory scope, and haven't needed it for weeks, so I know I hadn't clicked it previously today.

Meaning most of the time I do that, which is often enough to make a post about it, I'll have to click Project because that's usually the scope I need Find in Files to be in.

I can click into the file first, then highlight text, but that's adding up a lot of steps that are counter-intuitive and should probably be unnecessary.

Any thoughts on that? I think JetBrains can fix that, at least have it behave intuitively.

1

Any thoughts on that? I think JetBrains can fix that, at least have it behave intuitively.

PhpStorm Issue Tracker is the place where you can report bugs and feature requests.

0

OK so I found in one case, when the focus was last in the Project panel, if I select some text from one of the open files (as in, left-click to the left or right of a character then drag the mouse over text to select it), then open Find in Files using the keyboard shortcut, the selected scope will be Directory.

I could not reproduce this on my Windows 10.

Could be my set up (i.e. some plugin -- e.g. I'm using custom plugin for Quick Preview instead of the new built-in functionality and it may change things) .. or platform dependant issue.

Can you make some short video/screencast (show Find in Files working OK first (Project scope selected), then reproduce the issue). Maybe I'm doing it wrong + will help JetBrains folks reproducing it as well.

0

I discovered that Find in Files (using the keyboard shortcut) will also default to Directory if I was just using the Find or Replace box (at the top of the file tab) even while last editing code in the file and not having clicked anything in the Project panel for a while. So, that's really irritating, because I use Find and Replace a lot.

 

1

Vadiru, it must be this one: https://youtrack.jetbrains.com/issue/IDEA-270761
Please check how it goes in 2021.2 EAP #5 once we release it today.
https://blog.jetbrains.com/phpstorm/
https://www.jetbrains.com/phpstorm/nextversion/

Update: Sorry, the fix is actually already available, our EAP #5 took place a week ago.

1

This is not intuitive at all.

The IDE should not silently change a setting inside a dialog that can be used anywhere just because a directory in the Project tool window has focus when I invoke the dialog.

If I invoke the Find Files dialog and set it to Scope, the IDE should not change that back to directory unless i explicitly tell it to. An acceptable case (maybe) would be when I right click a directory and choose an option clearly named "Find files in this directory...". Then, when I invoke that dialog again from another place (the editor, for example), it should revert to my prefered setting (Scope).

6

You can submit this to our tracker at https://youtrack.jetbrains.com/newIssue describing that in details. Developers are rarely reading the forums, so if you want to be heard by the decision-making teams, please file feature requests at our tracker.

Personally I prefer the current Find In Files behavior.

0

It really should use the last search scope, however overridden by obvious contexts like right-clicking from a directory name.

Such that double-clicking a word in a file tab then opening Find in Files uses scope "whatever I last used", but right-clicking from a directory in Project panel opens it in scope Directory; right-clicking the Project name instead opens it in Project scope. Right-clicking from a directory name in the breadcrumb trail at the top should of course open in Directory scope. I mean, this is intuitive. You know, logically consistent. Right now it's schizophrenic.

Thank you for posting the tracker link, I just wanted these statements here at least since this forum is probably found more often than the tracker (and should be since most issues have fixes stated here).

1

Thanks for the clarification, I can see your point.

0

For anyone who wants the "Find/Replace in Files..." dialog window to always use the previously selected scope, and not have it automatically switch to "Directory" when the dialog window is opened while the project tool window is focused, I just added a comment about the workaround I use here:

https://youtrack.jetbrains.com/issue/IDEA-87037/Usability-Find-in-Path-NOT-in-Whole-project#focus=Comments-27-6077554.0-0

3

It is unacceptable that still in 2024 this is not fixed and still an issue.  Very annoying!  Of course, the default should be to search everywhere in the project!  Who thought that search in files could silently switch to search in directory?!

1

I have been troubled by this problem for a long time. One day, when I searched for the keyword 'find', I suddenly discovered an option. After checking it, the whole world became better. You can also give it a try.

In Advanced Settings's Search scopes in Find, Replace, Rename part, check 'Keep last selected search scope' option.

5

I found it under a separate section,  Search Scopes…

3

Andreimiculita thank you for this! Seems to be an effective solution. Constantly switching back to “In Project” had been annoying me for ages :)

0

Andreimiculita you're a hero - thank you. That setting is not in a very intuitive place…

0

Please sign in to leave a comment.