-
Notifications
You must be signed in to change notification settings - Fork 29.4k
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
Add option to move editors with workbench.editor.moveToActiveGroupIfOpen
#205442
base: main
Are you sure you want to change the base?
Add option to move editors with workbench.editor.moveToActiveGroupIfOpen
#205442
Conversation
@microsoft-github-policy-service agree |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dude, this is amazing. I think this is going to help a lot of people coming from vim/neovim, Emacs, and other keyboard-centric editors.
The only other thing I can think of is to update Working without Tabs in the docs to something like:
(I think this fits best under the "Working without Tabs" section.)
Simulating Buffers
If you're coming from buffer-centric editors such as Emacs or vi, you can emulate that workflow with:
"workbench.editor.showTabs": none, // or 'single'
"workbench.editor.revealIfOpen": true,
"workbench.editor.revealIfOpenInActiveGroup": true,
"workbench.editor.closeEmptyGroups": false,
VS Code has a model where Editors live hierarchically within Editor Groups, and to split your screen you must use Editor Groups. Using revealIfOpen
with revealIfOpenInActiveGroup
causes Quick Open to move already-open Editors into the active Editor Group. This allows you to emulate buffer-centric environments—no tabs, split your screen, and you can view any Editor within any Editor Group without opening a file multiple times.
I agree that we should add this in a PR in https://github.com/microsoft/vscode-docs if this PR gets accepted. I would also add that |
@jonathanjameswatson Good call on |
This is in preparation for the option `revealIfOpenInActiveGroup` which is being tracked in microsoft/vscode#204942 and has PR in microsoft/vscode#205442.
I think |
OK, I will rename it quickly! |
@gjsjohnmurray I have now renamed the configuration option and confirmed that it still works. |
I am not sure the editor group finder is the best place for this. It is not being used in all cases, only when the group is not specified explicitly. We already have a location in our editor resolver where we look for an existing editor and move it conditionally:
This is for editors that can only be opened once for a resource, so I wonder if the option could apply here as well. @lramos15 any objections? |
This is sort of a special case that has to do with the inability to resolve the editor otherwise. I'm not sure the resolver should own user configurations about editor position since its main focus is just on editor types. Also then you wonder if other reveal related settings would move to the resolver? This is a small change so not a huge deal for now but I do worry if over time this will create code debt. Let me know your thoughts. |
I still think that this line is not 100% correct: We are in the process of trying to figure out which group to use and there we reference |
It looks like you are right to say that this is not fully correct. If the editor grid is:
Then opening editor B to the side will result in:
rather than:
It definitely doesn't help that the line you mention only applies when Something that I find interesting here is that if you have:
and you open editor B to the side, you always seem to get:
even if |
@jonathanjameswatson hi, thanks for this code change! I think this is going to make life a lot easier for vim/emacs users to onboard to vscode since will make vscode's editor concept to behave more like the buffer systems in those two editors. @bpasero I saw this PR has been here for a while, wondering if there is anything we from open source community could do to help check this in? |
Hi, I do need to have another go at implementing this feature since the first attempt wasn't fully correct. If you would like to help, the first step would be to figure out a function that can be changed in a way that can handle all situations. I think this could be done by putting some breakpoints in the editor resolver and experimenting with opening editors in different ways. For example, opening a definition to the side. |
@bpasero I have now fixed the implementation of this feature by modifying the block of code that you linked to. I have checked that this feature works with opening to the side. It still works with editor group locking and having I made some changes to I check the configuration service in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
@bpasero Thank you for coaching through this change. Can you review? We need one more review for the check. |
@jonathanjameswatson Maybe we should change the title of the PR to "Add option I'm testing this tonight and it works really nicely. It's working flawlessly over the past 60 minutes. Demo: https://app.screencast.com/e4b1UiiBoWHO0?tab=Details&conversation=X5VpzpDiGkj107qoKseGT4 This is an important change for anybody coming from Emacs, Neovim, or other buffer-based editors. It's also important for users that don't wish to use the mouse and file tree to open files, as they can lean on Quick Open (Cmd-P) harder and it wont open 1-file-per-split. It also makes other options such as |
The vscode-docs PR has been updated accordingly - microsoft/vscode-docs#7043 |
workbench.editor.revealIfOpen
workbench.editor.moveToActiveGroupIfOpen
@bpasero ^^ for review :) I think this feature is super useful for power users coming from Emacs/Vim community. |
Really nice work @jonathanjameswatson :) Any ETA on the second review? As others have stated, it would be nice to finally make the switch from Vim once this is merged. |
@bpasero ^^ |
Adds the
workbench.editor.revealIfOpenInActiveGroup
configuration option, which simply changesworkbench.editor.revealIfOpen
to make any already-opened editor in a non-active editor group move to the active editor group on reveal. This makes opening an editor match the behavior of Emacs and Vim in a general and purely opt-in way.Please let me know if there is anything I can do to help getting this PR merged.
Resolves #204942.
Demo:
2024-02-17.15-56-14.mp4
Edit: This configuration option is now called
workbench.editor.moveToActiveGroupIfOpen
Demo by @aguynamedben:
https://app.screencast.com/e4b1UiiBoWHO0?tab=Details&conversation=X5VpzpDiGkj107qoKseGT4