Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch first and second result in quickOpen if first result is the current editor #159301

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jacekkopecky
Copy link
Contributor

@jacekkopecky jacekkopecky commented Aug 26, 2022

Fixes #159299

This code intercepts quick-open pick lists and if the first pick is the same file as the current editor, it switches the first two results.

It's my first attempt to contribute to VSCode therefore it's more of an RFC, I guess. 8-)

To test this, go to quick open (ctrl-p or cmd-p), type something to find a file, open that file, then go to quick open, type the same something as before, and the same file shouldn't be the first pick this time.

@ghost
Copy link

ghost commented Aug 26, 2022

CLA assistant check
All CLA requirements met.

@jacekkopecky
Copy link
Contributor Author

Another benefit of this reordering is that a quick cmd-p enter sequence takes you to the previous editor.

@nikita-r
Copy link
Contributor

Another benefit of this reordering is that a quick cmd-p enter sequence takes you to the previous editor.

The disadvantage of course is that cmd-p cmd-p does not take you to the previous editor anymore which is the current behaviour.

@jacekkopecky
Copy link
Contributor Author

Quite right @nikita-r; I didn't know you could navigate in that list with cmd-p. As I don't use it, I need to learn more about that pattern of use: do you use the second cmd-p also after typing a query, or only when the first cmd-p already shows what you want?

@nikita-r
Copy link
Contributor

I don't really know how I use it TBH :) the secondary purpose of cmd-p is somewhat unexpected probably, but some people may be used to it by now...

I have read the issue though and I have a comment on it: consider Angular projects where there are three "paired" files: ProductList.component.html, ProductList.component.ts, ProductList.component.scss. Now, following the issue logic, you'd want the current file to be the third instead of the second. Hard to come up with a definitive logic here consistent with the Principle of Least Surprise.

@jacekkopecky
Copy link
Contributor Author

Again good point @nikita-r !

I think if you have multiple files, you would subconsciously expect to have to look in the list (not expect there to be one obviously right answer), or you'd add a distinguisher in the query. I could imagine if I worked with angular I'd learn to just type ht/ts/cs to the end of the query (e.g. plistht) to get where I want. But it feels entirely unnecessary when it's simply the other matching file.

I consider it very unlikely that the user would want to go to the file they're already in. I feel that when typing that quick open query, I'm specifying the file I want among the other files. Maybe the switching behaviour could be triggered by a non-empty query, and even controlled by settings.

In Atom, when I needed this years ago, I ended up making an extension that tweaked the default behavior of the editor. I think VSCode extensions are more constrained (not that that's necessarily a bad thing) so I don't think the same approach is available here.

@jacekkopecky jacekkopecky force-pushed the active-editor-first-quick-pick branch from 824b167 to 8f0c7a6 Compare February 18, 2024 11:48
@jacekkopecky
Copy link
Contributor Author

jacekkopecky commented Feb 18, 2024

I have rebased the branch. The rationale stands: when using the "go to file" picker, when I have typed something to search, I'm unlikely to want to go to the active file, therefore it shouldn't be the first result.

This PR switches the first and second results if the first result is the active file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Switch first and second result in quickOpen if first result is the current editor
3 participants