microsoft / vscode

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

Add option to automatically move files to current tab group on open #204942

Open jonathanjameswatson opened 7 months ago

jonathanjameswatson commented 7 months ago

From @aguynamedben in https://github.com/microsoft/vscode/issues/41289:

I wish to live in a "don't-care-about-tabs" world but still want a way to split my editor's UI. However, the idea of tabs and tab groups seems deeply embedded into VS Code's ability to split windows, so I'm skeptical this is coming any time soon.

The best way out of this I can think of is some kind of settings such as:

"workbench.editor.moveToCurrentTabGroupIfOpen": true,

This would be similar to workbench.editor.revealIfOpen but opening a file that's already open in another tab group would move that file into the current tab group. Then I could disable all tab-centric UIs in VS Code and indiscriminately open any file within any split and not end up with a mess of duplicate files open across many tab groups. I think this might be sufficient for most tab-haters.

Working without Tabs could say:

If you're used to text-focused editors such as Emacs or vi and simply want to view any open file within any split without regard for tab or tab groups, set:

"workbench.editor.showTabs": true, "workbench.editor.revealIfOpen": true, "workbench.editor.moveToCurrentTabGroupIfOpen": true

With this setup, the underlying tabs and tab groups system will continue power which files are shown in which visual split, but that will be mostly irrelevant in day-to-day use. You wont see tabs, and opening a file will "move" the open file into whatever tab group ("visual split") you're focused on, similar to Emacs buffers and "windows".

https://github.com/microsoft/vscode/issues/41289 was originally closed as it was out of scope. However, this suggested feature does not seem out of scope and seems easier to implement than just removing editor groups altogether. I would be happy to try to implement this.

jonathanjameswatson commented 7 months ago

It seems like this might have already been somewhat implemented by @mkcode in https://github.com/microsoft/vscode/pull/134525 over 2 years ago. Is there any reason why this hasn't been merged and is there anything I can do to help get it merged?

mkcode commented 7 months ago

I'll chime in again just to share my experience and perspective with all this:

I completely understand microsoft's values in making vscode as accessible as possible. And, vscode is so close to be able to make people that prefer keyboard oriented approaches (usually coming from vim or eMacs) happy as well. It's just one or two "opt-in" settings away, meaning there would be no changes to the out of the box user experience.

Ultimately, I was unable to create a consistent keyboard oriented workflow in vscode, and have therefore been using neovim. A lost user that could have been supported, by allowing an opt-in setting change to unlock keyboard oriented workflows.

aguynamedben commented 7 months ago

+1

@jonathanjameswatson interesting that it doesn't seem that difficult to implement. #134525 is pretty close, I'd just want it to move the tab into current tab group from quick open (not open again).

Hmmm, I've never hacked on VS Code, but given that the other PR is 20 lines and I think there could be a compelling 2 minute video "how to setup VS Code like Neovim or Emacs" it could be pretty compelling and I don't see why it wouldn't be merged.

jonathanjameswatson commented 7 months ago

I think it makes sense to move the editor to the current tab group rather than re-open it – with re-opening, if you only use quick open, then you could presumably end up with all editors being in all tab groups.

I believe complexity may come from the interaction between revealIfOpen and moveToCurrentTabGroupIfOpen. It would not be an unreasonable to assume that moveToCurrentTabGroupIfOpen would not require revealIfOpen to be set, but if this was the case then it would not be clear what would happen if both were set. Perhaps we could use a name like moveToCurrentTabGroupOnOpenReveal instead? Although, perhaps that is too verbose.

jonathanjameswatson commented 7 months ago

I have made a PR that implements this feature: #205442

Demo here:

https://github.com/microsoft/vscode/assets/23344719/0598e320-1e7d-43c4-a1cc-ab7b372c139d

aguynamedben commented 7 months ago

@jonathanjameswatson Amazing!!! It works just like I imagined.

This will really help users coming from Emacs or vi. Users of those editors are accustomed to splitting windows into "frames" or "panes", then being able to recall any buffer into any frame without the file being opened a 2nd time. Your PR and revealIfOpenInActiveGroup makes that possible in VS Code. Without this, users must open a file once-per-Editor Group which creates a mess and kills the "fast switching". This is especially confusing for users who want to do side-by-side editing with tabs turned off.

I wrote these docs that I think should go under the "Working without Tabs" section, but I don't see how to edit the docs in the vscode repo.

Docs: https://github.com/microsoft/vscode/pull/205442#pullrequestreview-1886995297

aguynamedben commented 7 months ago

@mkcode Can you review the PR and docs in my approval as well? Thank you!

VSCodeTriageBot commented 7 months ago

This feature request is now a candidate for our backlog. The community has 60 days to upvote the issue. If it receives 20 upvotes we will move it to our backlog. If not, we will close it. To learn more about how we handle feature requests, please see our documentation.

Happy Coding!

aguynamedben commented 7 months ago

Docs PR: https://github.com/microsoft/vscode-docs/pull/7043

sutram commented 7 months ago

This would be great!

VSCodeTriageBot commented 7 months ago

:slightly_smiling_face: This feature request received a sufficient number of community upvotes and we moved it to our backlog. To learn more about how we handle feature requests, please see our documentation.

Happy Coding!

aguynamedben commented 6 months ago

@bpasero @benibenj This feature has been implemented (PR) and documented (PR).

Who can me and @jonathanjameswatson work with to get the PR merged? This is my first time contributing to VS Code and it's been a good experience so far!

aguynamedben commented 1 week ago

@benibenj Is there any way to bump this?

The feature is implemented, works great, is documented, is under an option, and has the votes required.

It seems like it's just stuck in VS Codes "backlog" process. This feature will help users switch from vim/neovim/Emacs and other buffer-based editors to VS Code.

benibenj commented 1 week ago

Pinging @loganrosen as the change is part of the Editor Resolver Service

loganrosen commented 1 week ago

I think you meant @lramos15 🙂

benibenj commented 6 days ago

Exactly, I meant @lramos15, sorry 😅