Skip to content

workspace: Add ActivateLastPane action - #49853

Merged
smitbarmase merged 2 commits into
zed-industries:mainfrom
gh-xj:workspace/activate-last-pane
Feb 24, 2026
Merged

workspace: Add ActivateLastPane action#49853
smitbarmase merged 2 commits into
zed-industries:mainfrom
gh-xj:workspace/activate-last-pane

Conversation

@gh-xj

@gh-xj gh-xj commented Feb 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Add workspace::ActivateLastPane so users can bind a shortcut (for example cmd-9) to focus the last pane.

Why

Today, the closest option is workspace::ActivatePane with an index (for example 8), but that has side effects: when the index does not exist, it creates/splits panes (activate_pane_at_index fallback).

ActivateLastPane gives a stable, no-surprises target: focus the rightmost/last pane in current pane order, never create a new pane.

Context

This capability has been requested by users before:

Prior art

VS Code exposes explicit editor-group focus commands and index-based focus patterns (e.g. workbench.action.focusSecondEditorGroup ... focusEighthEditorGroup) in its workbench commands:

Zed already follows numbered pane focus in default keymaps (ActivatePane 1..9 on macOS/Linux/Windows), so adding a dedicated "last pane" action is a small, natural extension:

  • assets/keymaps/default-macos.json
  • assets/keymaps/default-linux.json
  • assets/keymaps/default-windows.json

Change

  • Added workspace::ActivateLastPane
  • Implemented Workspace::activate_last_pane(...)
  • Wired action handler in workspace listeners
  • Added test_activate_last_pane

Validation

  • cargo test -p workspace test_activate_last_pane -- --nocapture
  • cargo test -p workspace test_pane_navigation -- --nocapture
  • cargo fmt --all -- --check

Risk

Low: focus-only behavior, no layout/data changes, no default keymap changes.

Release Notes:

  • Added workspace::ActivateLastPane action for keybindings that focus the last pane.

Copilot AI review requested due to automatic review settings February 22, 2026 19:51
@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Feb 22, 2026
@zed-community-bot zed-community-bot Bot added the first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions label Feb 22, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new workspace-level action to focus the last pane, enabling users to bind a shortcut (e.g. cmd-9) similar to existing “last item” navigation.

Changes:

  • Added workspace::ActivateLastPane to the workspace action set.
  • Implemented Workspace::activate_last_pane(...) and wired it into workspace action listeners.
  • Added test_activate_last_pane to validate focusing behavior across multiple panes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 6381 to 6383
.on_action(cx.listener(|workspace, _: &ActivateNextPane, window, cx| {
workspace.activate_next_pane(window, cx)
}))

Copilot AI Feb 22, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ActivateNextPane is registered twice in this listener chain (once around line 6381 and again around line 6409). Div::on_action accumulates listeners, so dispatching ActivateNextPane will run both handlers and advance focus twice (skipping a pane). Remove one of these registrations.

Suggested change
.on_action(cx.listener(|workspace, _: &ActivateNextPane, window, cx| {
workspace.activate_next_pane(window, cx)
}))

Copilot uses AI. Check for mistakes.
Comment thread crates/workspace/src/workspace.rs Outdated
}

pub fn activate_last_pane(&mut self, window: &mut Window, cx: &mut App) {
if let Some(last_pane) = self.center.panes().last().cloned() {

Copilot AI Feb 22, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

activate_last_pane currently calls self.center.panes() which allocates a Vec just to get the final pane. Since PaneGroup already exposes last_pane(), prefer using that to avoid allocation and to match the semantic intent more directly.

Suggested change
if let Some(last_pane) = self.center.panes().last().cloned() {
if let Some(last_pane) = self.center.last_pane() {

Copilot uses AI. Check for mistakes.
@smitbarmase smitbarmase self-assigned this Feb 24, 2026
@zed-industries-bot

Copy link
Copy Markdown
Contributor
Messages
📖

This PR includes links to the following GitHub Issues: #- 17503
If this PR aims to close an issue, please include a Closes #ISSUE line at the top of the PR body.

Generated by 🚫 dangerJS against a266d8a

@smitbarmase
smitbarmase merged commit 269b03f into zed-industries:main Feb 24, 2026
27 checks passed
@smitbarmase

Copy link
Copy Markdown
Member

Thanks. It's a nice addition.

tahayvr pushed a commit to tahayvr/zed that referenced this pull request Mar 4, 2026
## Summary

Add `workspace::ActivateLastPane` so users can bind a shortcut (for
example `cmd-9`) to focus the last pane.

## Why

Today, the closest option is `workspace::ActivatePane` with an index
(for example `8`), but that has side effects: when the index does not
exist, it creates/splits panes (`activate_pane_at_index` fallback).

`ActivateLastPane` gives a stable, no-surprises target: focus the
rightmost/last pane in current pane order, never create a new pane.

## Context

This capability has been requested by users before:
- zed-industries#17503 (comment)

## Prior art

VS Code exposes explicit editor-group focus commands and index-based
focus patterns (e.g. `workbench.action.focusSecondEditorGroup` ...
`focusEighthEditorGroup`) in its workbench commands:
-
https://github.com/microsoft/vscode/blob/main/src/vs/workbench/browser/parts/editor/editorCommands.ts#L675-L724

Zed already follows numbered pane focus in default keymaps
(`ActivatePane` 1..9 on macOS/Linux/Windows), so adding a dedicated
"last pane" action is a small, natural extension:
- `assets/keymaps/default-macos.json`
- `assets/keymaps/default-linux.json`
- `assets/keymaps/default-windows.json`

## Change

- Added `workspace::ActivateLastPane`
- Implemented `Workspace::activate_last_pane(...)`
- Wired action handler in workspace listeners
- Added `test_activate_last_pane`

## Validation

- `cargo test -p workspace test_activate_last_pane -- --nocapture`
- `cargo test -p workspace test_pane_navigation -- --nocapture`
- `cargo fmt --all -- --check`

## Risk

Low: focus-only behavior, no layout/data changes, no default keymap
changes.

Release Notes:

- Added `workspace::ActivateLastPane` action for keybindings that focus
the last pane.

---------

Co-authored-by: xj <gh-xj@users.noreply.github.com>
@injust injust mentioned this pull request Mar 4, 2026
1 task
jonx pushed a commit to jonx/zed-aros that referenced this pull request Jul 17, 2026
## Summary

Add `workspace::ActivateLastPane` so users can bind a shortcut (for
example `cmd-9`) to focus the last pane.

## Why

Today, the closest option is `workspace::ActivatePane` with an index
(for example `8`), but that has side effects: when the index does not
exist, it creates/splits panes (`activate_pane_at_index` fallback).

`ActivateLastPane` gives a stable, no-surprises target: focus the
rightmost/last pane in current pane order, never create a new pane.

## Context

This capability has been requested by users before:
- zed-industries#17503 (comment)

## Prior art

VS Code exposes explicit editor-group focus commands and index-based
focus patterns (e.g. `workbench.action.focusSecondEditorGroup` ...
`focusEighthEditorGroup`) in its workbench commands:
-
https://github.com/microsoft/vscode/blob/main/src/vs/workbench/browser/parts/editor/editorCommands.ts#L675-L724

Zed already follows numbered pane focus in default keymaps
(`ActivatePane` 1..9 on macOS/Linux/Windows), so adding a dedicated
"last pane" action is a small, natural extension:
- `assets/keymaps/default-macos.json`
- `assets/keymaps/default-linux.json`
- `assets/keymaps/default-windows.json`

## Change

- Added `workspace::ActivateLastPane`
- Implemented `Workspace::activate_last_pane(...)`
- Wired action handler in workspace listeners
- Added `test_activate_last_pane`

## Validation

- `cargo test -p workspace test_activate_last_pane -- --nocapture`
- `cargo test -p workspace test_pane_navigation -- --nocapture`
- `cargo fmt --all -- --check`

## Risk

Low: focus-only behavior, no layout/data changes, no default keymap
changes.

Release Notes:

- Added `workspace::ActivateLastPane` action for keybindings that focus
the last pane.

---------

Co-authored-by: xj <gh-xj@users.noreply.github.com>
jolutz pushed a commit to jolutz/zed that referenced this pull request Aug 8, 2026
## Summary

Add `workspace::ActivateLastPane` so users can bind a shortcut (for
example `cmd-9`) to focus the last pane.

## Why

Today, the closest option is `workspace::ActivatePane` with an index
(for example `8`), but that has side effects: when the index does not
exist, it creates/splits panes (`activate_pane_at_index` fallback).

`ActivateLastPane` gives a stable, no-surprises target: focus the
rightmost/last pane in current pane order, never create a new pane.

## Context

This capability has been requested by users before:
- zed-industries#17503 (comment)

## Prior art

VS Code exposes explicit editor-group focus commands and index-based
focus patterns (e.g. `workbench.action.focusSecondEditorGroup` ...
`focusEighthEditorGroup`) in its workbench commands:
-
https://github.com/microsoft/vscode/blob/main/src/vs/workbench/browser/parts/editor/editorCommands.ts#L675-L724

Zed already follows numbered pane focus in default keymaps
(`ActivatePane` 1..9 on macOS/Linux/Windows), so adding a dedicated
"last pane" action is a small, natural extension:
- `assets/keymaps/default-macos.json`
- `assets/keymaps/default-linux.json`
- `assets/keymaps/default-windows.json`

## Change

- Added `workspace::ActivateLastPane`
- Implemented `Workspace::activate_last_pane(...)`
- Wired action handler in workspace listeners
- Added `test_activate_last_pane`

## Validation

- `cargo test -p workspace test_activate_last_pane -- --nocapture`
- `cargo test -p workspace test_pane_navigation -- --nocapture`
- `cargo fmt --all -- --check`

## Risk

Low: focus-only behavior, no layout/data changes, no default keymap
changes.

Release Notes:

- Added `workspace::ActivateLastPane` action for keybindings that focus
the last pane.

---------

Co-authored-by: xj <gh-xj@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants