Local variable Cmd+click trace defaults to All Places instead of Current File or last-used scope

I forget what the name of the Keymap action is for this, but it's when you hover the mouse pointer over a var, then hit Cmd+click (Mac) or Ctrl+click (Windows) to see all usages of the var.

Because I usually want to see usages of that var after that var is declared, the problem is that PHPStorm pops up all usages everywhere apparently regardless of whether it could be chronologically used in code execution or not (and regardless of file includes), as in, the result scope shows "All Places" every time even though I typically just want to see all subsequent uses of it in the file initially:

Even if I want a wider scope, I'd still prefer to see the last-selected scope rather than it always default to "All Places".

Did I miss somewhere to have it behave more sensibly?

7 comments
Comment actions Permalink

I forget what the name of the Keymap action is for this

It's called Find Usages.

regardless of whether it could be chronologically used in code execution or not (and regardless of file includes)

In normal circumstances, it's impossible to tell in what order your files get executed in because of autoloading, so PhpStorm doesn't even try to analyze include/require statements.

Even if I want a wider scope, I'd still prefer to see the last-selected scope rather than it always default to "All Places".

If you choose the scope in the Find Usages Settings dialog behind the Gear icon in the popup, it'll be saved for future invocations.
Would that do?

1
Comment actions Permalink

I don't see a scope setting from the gear icon...

 

I'm using PHPStorm version 2021.2.2. I'm not sure where you're seeing the "Find Usages Settings" dialog.

0
Comment actions Permalink

Find Usages Settings is the dialog you show on your last screenshot. It doesn't have the dropdown because you seem to invoke it on a variable that has a limited scope, like a method local variable or something.

If it's not the case, please share a code snippet. Thanks!

0
Comment actions Permalink

If something is named one thing, please don't name it something else especially not in a gray highlight as if that's it's proper/displayed name. That just causes confusion. We can't always infer what you mean with inconsistent terminology, especially when it's highlighted in gray, and especially when many of us have had to work with very particular UIs where these differences can matter based on context.

Does the box sometimes show up named as "Find Usages Settings"? I don't see the point of that.

The box has never been called "Find Usages Settings" anywhere that I've seen except in your usage of it, which obviously threw me off, so please don't refer to it as that, just "Find Usages", like "the Find Usages dialog box". Intuitively there could be a "Find Usages" dialog box and then a "Find Usages Settings" dialog box that could refer to settings of the previous box, which is obviously what I thought at the time based on your explanation. Please, we can't read minds; name things consistently.

0
Comment actions Permalink

The box has never been called "Find Usages Settings" anywhere that I've seen except in your usage of it

The menu item that invokes this dialog is called Find Usages Settings, you can find it in Navigate | Fine Usages.

0
Comment actions Permalink

Why does it have two names?! It drives me crazy when terminology is inconsistent.

0
Comment actions Permalink

To distinguish between the command itself and the command that invokes the settings window, I suppose. Not sure why the settings window is titled "Find Usages" and not "Find Usages Settings" though.

0

Please sign in to leave a comment.