Skip to content

Add Vim-like focus history navigation (back/forward)#1863

Open
richard134 wants to merge 2 commits intonikitabobko:mainfrom
richard134:feature/1024-focus-history-navigation
Open

Add Vim-like focus history navigation (back/forward)#1863
richard134 wants to merge 2 commits intonikitabobko:mainfrom
richard134:feature/1024-focus-history-navigation

Conversation

@richard134
Copy link

Implements Vim-like focus history navigation (focus back/focus forward) and makes focus-back-and-forth resilient to closed windows by using the shared history stack.

Closes #1024

Implements Vim-like focus history navigation for the focus command,
allowing users to navigate back and forward through their focus history
similar to Vim's Ctrl-O and Ctrl-I jump list behavior.

New commands:
- `focus back` - Navigate to the previously focused window
- `focus forward` - Navigate forward after going back

Key features:
- History is automatically recorded when focus changes
- Forward history is truncated when focusing a new window (Vim behavior)
- Closed windows are automatically skipped
- Maximum history size of 100 entries
- Incompatible with other focus flags (--boundaries, etc.)

Closes nikitabobko#1024
Unify focus-back-and-forth with the focus history stack instead of
maintaining a separate _prevFocus variable. This makes the command
resilient to closed windows - when the previous window is closed,
it will fallback to the next valid window in history.

Also seeds the history with the initial focus on first focus change
so back-and-forth works immediately after startup.

Closes nikitabobko#1024
@richard134 richard134 force-pushed the feature/1024-focus-history-navigation branch from b52a080 to 364dd1e Compare December 22, 2025 08:23
Davincible added a commit to Davincible/AeroSpace that referenced this pull request Feb 11, 2026
…rward)

# Conflicts:
#	Sources/Common/cmdArgs/impl/FocusCmdArgs.swift
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve focus-back-and-forth: remember the whole focus history stack

2 participants