zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
45.98k stars 2.56k forks source link

Unified tab bar for all splits #12243

Open tmke8 opened 3 months ago

tmke8 commented 3 months ago

Check for existing issues

Describe the feature

Right now, each split pane has its own tab bar (as in VS Code and probably many other editors), but I think this does not represent well how programmers actually use splits. I usually just have a bunch of files open, and then at each moment, I decide which two files I want to be looking at right now. The concept of "this file is open in the right split but not in the left split" doesn't really make sense for this. It's completely random which file is open where. Sometimes I even have the same file open in both splits. (There could be a situation where I'm comparing two different projects and I only open files from project A on the left and files from project B on the right, and so the distinction would be meaningful, but I don't think I've ever done this.)

So, I'm proposing to have a single tab bar for all open files and have the split panes just display one of these open files.

See the attached screenshot for how this looks in my neovim setup.

One major advantage of this is that I can really quickly switch to an open file. You see in the screenshot that all the open buffers are numbered, and I have keyboard shortcuts such that I just have to press space + 3 to switch to the third file. (I stole this idea from Sublime.) This manner of switching files always feels super fast and I think would fit with zed's motto of "code at the speed of thought"!

Notice also how there is just more space to show currently open files.

EDIT: one objection is maybe that when you click on a tab, it's not clear in which split the tab will open, but that problem also exists when you click on one of the files in the file tree: it opens in the split that was last active

If applicable, add mockups / screenshots to help present your vision of the feature

screenshot from (neo)vim:

image

(on the left, app.rs is open, and on the left main.rs, but there is only one bar for the open files)

baldwindavid commented 3 months ago

I agree with the conceptual sentiment here, only as applied to the "Tab Switcher"; I hide the tabs anyway and solely use the tab switcher / file finder. Currently, the tab switcher is scoped to the current pane. I'd much prefer it displayed any files open in any pane allowing me to open them in the current pane whether they were originally opened there or not.

Even though I don't use "visual" tabs, a couple notes on that concept:

Wragdan commented 2 months ago

Came here looking if someone else had the same issue. I was looking into replicating the list buffers functionality from telescope, and I think this could work. Looking into the code to see how I can implement this (although I'm still learning the code base), or at least add a setting to enable this behavior.

caerphoto commented 2 months ago

This reflects the way I use tabs in NeoVim too – they're not really connected to individual files, but are more like 'workspaces' within a project: each tab holds an arbitrary number of splits, and each split can display whatever buffer I need. Sometimes I have a tab with a single vertical split with each side showing the same file in two different positions. Sometimes, I'll have a tab with a 2x2 split arrangements, so I can for example have various related small HTML template files on screen at once.

In each case, the tab is the primary grouping element, and the splits are subdivisions of that group. This is basically the opposite of how Zed (and VSCode, for that matter) work at present, where splits are the primary groups, and tabs operate within them.

neovim-tab-layout-example

Here I have three html template files open in this tab; in the previous tabs I have some Rust source files open that deal with HTTP responses etc.; in the next tab are some frontend JS and CSS files; the last tab contains some project config stuff.

tmke8 commented 2 months ago

I think issue #10819 is more relevant for what you are imagining than this one here.

I opened this issue for a much smaller change: just moving the list of open files from the splits to a global position. Such that the list of open files is not specific to a split anymore, but "global".

This is actually how the file tree currently works: there is only one file tree and by clicking on files there, you can open the file in any split you want (it depends on which split was last focused). That's how I imagine it would work with list of open files as well.

Before:

image

After:

Screenshot from 2024-06-26 14-30-46

caerphoto commented 2 months ago

Ah, I see what you mean now, yeah, looks like you're right about #10819 , thanks for the heads up.