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

Tab Switcher #7653

Closed
4 tasks done
alygin opened this issue Feb 10, 2024 · 10 comments · Fixed by #7987
Closed
4 tasks done

Tab Switcher #7653

alygin opened this issue Feb 10, 2024 · 10 comments · Fixed by #7987
Labels
enhancement [core label] tabs Feedback for tabs behavior, navigation, style, etc workspace Feedback for workspace management, layout, interactions, etc

Comments

@alygin
Copy link
Contributor

alygin commented Feb 10, 2024

Check for existing issues

  • Completed

Describe the feature

When working on tabless editing mode (#6424), there was a discussion about the need to implement Tab Switcher -- a panel similar to the File Finder that would show the list of opened tabs in the active pane and allow to switch between them and close them right in this panel.

I tried to figure out how such switcher could look and how it could be implemented, and decided to file it as a separate feature request, because there's a lot of things to discuss (and probably to change in the code).

How it will look and work

zed-tab-switcher
  • Default shortcut is ctrl-tab. It also moves selection to the next item.
  • Selection is confirmed by either releasing of a modifier key (ctrl by default) or with a mouse click.
  • Items are sorted in the reverse order of the tab activation history.
  • Second item (if exists) is selected by default. This will allow to switch to the previous tab with a single keystroke.
  • We need item icons here to distinguish files from terminal, search results etc.
  • Close button is displayed when hover over item.
  • Implemented using the existing Picker functionality, but with the query editor hidden.

Tasks

How others do this

See comments below:

Related issues and PRs

@alygin alygin added admin read Pending admin review enhancement [core label] triage Maintainer needs to classify the issue labels Feb 10, 2024
@alygin
Copy link
Contributor Author

alygin commented Feb 10, 2024

VSCode

VSCode has several features that allow the user to naviage between opened tabs:

  1. Tab switcher, as described above, available through ctrl+tab shortcut:
vscode-tab-bar-menu
  1. Tab bar dropdown menu wit the "Show Opened Editors" action in it:
vscode-tab-bar-menu

When clicked, it displays a panel that is very similar to File Finder. Tabs of the selected pane (group) are listed in the reverse history order. Name, path, git status, modification mark etc. are the same as in the tabs, including the Close button:

vscode-opened-editors-list
  1. VSCode also has the Open Editors panel that can be displayed in the left pane, along with the project structure:
vscode-opened-editors-panel

VSCode doesn't have a setting that would allow to automatically close tabs when there're too many of them.

@alygin
Copy link
Contributor Author

alygin commented Feb 10, 2024

Jet Brains IDEA

IDEA doesn't provide such feature

See @alexander-irbis's comment: #7653 (comment)

@alygin
Copy link
Contributor Author

alygin commented Feb 10, 2024

Sublime Text

Sublime Text has an "Add" button and a simple dropdown list with opened tabs:

sublime-tab-bar-menu

@diocletiann
Copy link

If Zed had a unified bufferline this wouldn't be an issue.

@JosephTLyons JosephTLyons added workspace Feedback for workspace management, layout, interactions, etc tabs Feedback for tabs behavior, navigation, style, etc and removed triage Maintainer needs to classify the issue admin read Pending admin review labels Feb 13, 2024
This was referenced Mar 3, 2024
@alexander-irbis
Copy link

IDEA doesn't provide such feature

Idea provides such feature (with additional options where to switch). Also it allows to select elements in the list with arrows (while Ctrl is pressed).

image

@alygin
Copy link
Contributor Author

alygin commented Mar 12, 2024

Idea provides such feature

You're right, thanks for pointing that out! I've added a link to your comment.

@oxaronick
Copy link

If Zed supports ctrl-tab to switch between recent tabs the way VSCode and Firefox do, that will be great.

maxdeviant added a commit that referenced this issue Mar 18, 2024
At the moment, `Picker` always has an editor at the top, that allows the
user to search list elements by text. Sometimes, the UI doesn't need
such an editor. Like in the [tab
switcher](#7653) that will
confirm selection on the modifier keys release, so there will be no
searching capabilities.

This PR adds support for a "headless picker" that doesn't display an
editor. It only has an invisible element to hold input focus for
preventing it from jumping back to the workspace.

At the moment, none of the picker implementations is made headless. It's
for the future implementations. But I'd like to make it a separate PR to
keep it focused on this particular feature.

Release Notes:

- N/A

Related Issues:
- Part of #7653

---------

Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
ConradIrwin pushed a commit that referenced this issue Mar 21, 2024
This PR adds support for handling action releases &mdash; events that
are fired when the user releases all the modifier keys that were part of
an action-triggering shortcut.

If the user holds modifiers and invokes several actions sequentially via
shortcuts (same or different), only the last action is "released" when
its modifier keys released.

~The following methods were added to `Div`:~
- ~`capture_action_release()`~
- ~`on_action_release()`~
- ~`on_boxed_action_release()`~

~They work similarly to `capture_action()`, `on_action()` and
`on_boxed_action()`.~

See the implementation details in [this
comment](#8782 (comment)).

Release Notes:

- Added a fast-switch mode to the file finder: hit `p` or `shift-p`
while holding down `cmd` to select a file immediately. (#8258).

Related Issues:

- Implements #8757 
- Implements #8258
- Part of #7653 

Co-authored-by: @ConradIrwin
pjlast pushed a commit to pjlast/zed that referenced this issue Mar 26, 2024
This PR adds support for handling action releases &mdash; events that
are fired when the user releases all the modifier keys that were part of
an action-triggering shortcut.

If the user holds modifiers and invokes several actions sequentially via
shortcuts (same or different), only the last action is "released" when
its modifier keys released.

~The following methods were added to `Div`:~
- ~`capture_action_release()`~
- ~`on_action_release()`~
- ~`on_boxed_action_release()`~

~They work similarly to `capture_action()`, `on_action()` and
`on_boxed_action()`.~

See the implementation details in [this
comment](zed-industries#8782 (comment)).

Release Notes:

- Added a fast-switch mode to the file finder: hit `p` or `shift-p`
while holding down `cmd` to select a file immediately. (zed-industries#8258).

Related Issues:

- Implements zed-industries#8757 
- Implements zed-industries#8258
- Part of zed-industries#7653 

Co-authored-by: @ConradIrwin
mikayla-maki added a commit that referenced this issue Mar 27, 2024
The Tab Switcher implementation (#7653):
- `ctrl-tab` opens the Tab Switcher and moves selection to the
previously selcted tab. It also cycles selection forward.
- `ctrl-shift-tab` opens the Tab Switcher and moves selection to the
last tab in the list. It also cycles selection backward.
- Tab is selected and the Tab Switcher is closed on the shortcut
modifier key (`ctrl` by default) release.
- List items are in reverse activation history order.
- The list reacts to the item changes in background (new tab, tab
closed, tab title changed etc.)

Intentionally not in scope of this PR:
- File icons
- Close buttons

I will come back to these features. I think they need to be implemented
in separate PRs, and be synchronized with changes in how tabs are
rendered, to reuse the code as it's done in the current implementation.
The Tab Switcher looks usable even without them.

Known Issues:

Tab Switcher doesn't react to mouse click on a list item. It's not a tab
switcher specific problem, it looks like ctrl-clicks are not handled the
same way in Zed as cmd-clicks. For instance, menu items can be activated
with cmd-click, but don't react to ctrl-click. Since the Tab Switcher's
default keybinding is `ctrl-tab`, the user can only click an item with
`ctrl` pushed down, thus preventing `on_click()` from firing.

fixes #7653, #7321

Release Notes:

- Added Tab Switcher which is accessible via `ctrl-tab` and
`ctrl-shift-tab` (#7653) (#7321)

Related issues:

- Unblocks #7356, I hope 😄

How it looks and works (it's only `ctrl-tab`'s and `ctrl-shift-tab`'s,
no `enter`'s or mouse clicks):


https://github.com/zed-industries/zed/assets/2101250/4ad4ec6a-5314-481b-8b35-7ac85e43eb92

---------

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
Co-authored-by: Mikayla Maki <mikayla@zed.dev>
@maximvl
Copy link

maximvl commented Apr 3, 2024

Nice one! I hope a fuzzy-search feature can be added too, it is so convenient to use it after trying it in Emacs.

@failable
Copy link

failable commented Apr 4, 2024

@maximvl Filterable tab switcher would be very helpful. I also miss the ctrl-x b (switch-to-buffer) in Emacs.

@tymscar
Copy link

tymscar commented Jun 7, 2024

I can back up what @maximvl is saying. I'm coming from emacs and being able to fuzzy search open tabs (buffers) is a massive benefit!

The way the project switcher works is perfect. That's how the tab switcher should work too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement [core label] tabs Feedback for tabs behavior, navigation, style, etc workspace Feedback for workspace management, layout, interactions, etc
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants