microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.75k stars 29.1k forks source link

Expand all locations when using Find All References #197592

Open Hau-Hau opened 11 months ago

Hau-Hau commented 11 months ago

Hi,

There is no option to set alwaysExpand for References view.

To achieve this goal it is needed to:

image

Edit I have tested changes locally and created PR. Regarding implementation - I have set alwaysCollapse as default value to keep default behaviour consistent with current one.

Also worth mentioning is that this or very similar functionality has been requested long time ago by multiple people; e.g. https://github.com/microsoft/vscode-cpptools/issues/4333, https://github.com/microsoft/vscode/issues/104548

jrieken commented 11 months ago

Yeah, that's because we would need to load/open each file in order to expand it (we show a real textual preview) and that could be quite expensive

Hau-Hau commented 11 months ago

Is there anything specific what do you recommend to solve this problem?

My proposition is to handle it in same way as in Search view. By that I mean to create one more option called "auto" which would expand files with less than 10 results. So in result would be three options: auto, alwaysCollapse, alwaysExpand.

For last two days I was working with custom build of References view in which alwaysExpand option is enabled by default and I didn't found any performance issues. I'm not saying that it is not a problem, just wanted to highlight that this options is useful and users should have at least possibility to decide.

ds614 commented 7 months ago

@Hau-Hau, could you please tell me how to view your PR? I am interested in trying your changes locally. Thanks!

Hau-Hau commented 7 months ago

Hi @ds614, you will find PR under this link: https://github.com/microsoft/vscode/pull/197594

Also, if you would like to hardcode "expanded" state without rebuilding vscode and all of that troubles you can directly override extension.js. For Windows I'm using this command:

(Get-Content "C:\Users\$($env:UserName)\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\references-view\dist\extension.js") -replace '.Collapsed', '.Expanded' | Set-Content "C:\Users\$($env:UserName)\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\references-view\dist\extension.js"

However, it is a bit annoying approach as after every vscode update, this file is regenerated to original form.

ds614 commented 7 months ago

That's very helpful, thanks so much!

ds614 commented 7 months ago

And by the way... I agree with you that I don't see what harm there would be in having this as a setting that defaults to the old "collapsed" behavior. 🤷‍♂️

aguynamedben commented 4 months ago

+1. The setting could be a configurable limit. For example, the option could called referencesExpandResultsFileLimit which defaults to 1 but it could be set to 10 if you're okay with the performance trade.