Skip to content

Add window size commands and tab navigation hotkeys - #44

Merged
simeji merged 4 commits into
masterfrom
feature/size-and-tab-commands
Mar 28, 2026
Merged

Add window size commands and tab navigation hotkeys#44
simeji merged 4 commits into
masterfrom
feature/size-and-tab-commands

Conversation

@simeji

@simeji simeji commented Mar 28, 2026

Copy link
Copy Markdown
Owner

Summary

Implements a subset of the features proposed in #30, adapted to match the existing codebase conventions:

  • _ (hfull, ASCII 95) — maximize current window height (wincmd _) — resize mode only
  • | (vfull, ASCII 124) — maximize current window width (wincmd |) — resize mode only
  • = (sizeeq, ASCII 61) — equalize all window sizes (wincmd =) — resize mode only
  • J (tabl, ASCII 74) — switch to previous tab — all modes
  • K (tabr, ASCII 75) — switch to next tab — all modes

All new keycodes are configurable via g:winresizer_keycode_* variables and documented in README.md.

Changes from #30

  • Close key excluded (already shipped in [Feature Request] Window close hotkey #29 as x)
  • sleep 1 pattern not used — dispatch executes commands directly, consistent with all other hotkeys
  • No new autoload functions needed; vim built-in commands used directly

Test plan

  • All 36 vader tests pass (vim -Es -u test/vimrc '+Vader! test/winresizer.vader')
  • 10 new test cases covering keycode defaults and hotkey behaviour for all 5 new commands
  • CI will run on push

Implement hfull (_), vfull (|), sizeeq (=) for window size control in
resize mode, and tabl (J) / tabr (K) for tab navigation across all modes.
All new keycodes are configurable via g:winresizer_keycode_* variables.

Closes #30 (partial: excludes close key already implemented in #29)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: eb744dc2c9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread plugin/winresizer.vim
Comment on lines +343 to +346
elseif c == s:codeList['tabl'] && has_key(l:commands, 'tabl') "J
exe l:commands['tabl']
elseif c == s:codeList['tabr'] && has_key(l:commands, 'tabr') "K
exe l:commands['tabr']

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Refresh mode commands after tab navigation

In s:startResize, the new tabl/tabr handlers execute tabprevious/tabnext but leave l:commands unchanged, so the loop continues using command state captured on the previous tab. In resize mode this state includes edge-dependent left/right/up/down behavior and a winrestcmd() cancel snapshot, which can become incorrect immediately after J/K when tabs have different window layouts (for example, h can resize in the opposite direction and q can restore the wrong geometry). Rebuild l:commands for the current mode after each tab switch to keep behavior consistent.

Useful? React with 👍 / 👎.

After J/K switches tabs, edge detection and winrestcmd() snapshots in
l:commands reflect the previous tab's layout. Introduce s:commandsForMode()
and call it after each tab switch so resize direction and cancel behavior
are always consistent with the current tab.
@simeji

simeji commented Mar 28, 2026

Copy link
Copy Markdown
Owner Author

Addressed in 9b0fa03 (re: Codex review): introduced s:commandsForMode() and call it after each J/K tab switch, so both the edge-dependent resize directions and the winrestcmd() cancel snapshot are rebuilt against the new tab's layout. Added a test case to cover the cancel behavior after tab navigation.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9b0fa03a01

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread plugin/winresizer.vim
Comment on lines +382 to +383
else
return s:tuiResizeCommands()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve GUI resize mode when rebuilding commands

When WinResizerStartResizeGUI is active, pressing J/K triggers command refresh via s:commandsForMode(l:commands['mode']), but this helper maps 'resize' to s:tuiResizeCommands() unconditionally. That means a GUI session silently flips to the TUI command set after the first tab navigation, so subsequent h/j/k/l and q operate on split/window layout state instead of GUI &columns/&lines, which is a functional regression for GUI users.

Useful? React with 👍 / 👎.

Rename guiResizeCommands mode from 'resize' to 'gui_resize' so that
s:commandsForMode() can distinguish TUI and GUI resize sessions and
return the correct command set after J/K tab navigation.
@simeji

simeji commented Mar 28, 2026

Copy link
Copy Markdown
Owner Author

Addressed in 36c5140 (re: Codex review): renamed the GUI resize mode identifier from 'resize' to 'gui_resize' and added a branch in s:commandsForMode() to return s:guiResizeCommands() for that case. TUI and GUI resize sessions are now distinguished correctly after tab navigation.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 36c5140217

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread plugin/winresizer.vim
exe l:commands['sizeeq']
elseif c == s:codeList['tabl'] && has_key(l:commands, 'tabl') "J
exe l:commands['tabl']
let l:commands = s:commandsForMode(l:commands['mode'])

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve GUI cancel snapshot after tab navigation

Rebuilding l:commands immediately after J/K recreates gui_resize commands, including a new cancel value based on the current &columns/&lines. In GUI resize mode this means q stops undoing earlier frame-size changes once a tab switch occurs (e.g., resize with h/l, press J, then q leaves the resized dimensions in place). Keep the original GUI cancel snapshot when handling tab navigation so cancel still restores the pre-session size.

Useful? React with 👍 / 👎.

@simeji

simeji commented Mar 28, 2026

Copy link
Copy Markdown
Owner Author

Re: Codex review on GUI cancel snapshot: skipping this one intentionally.

For TUI mode, rebuilding l:commands after tab switch is correct — the old winrestcmd() snapshot references window numbers from the previous tab and would be meaningless (or harmful) on the new tab. For GUI mode, preserving the original cancel across tab switches would be more accurate, but the behaviour depends on user expectation ("undo all session changes" vs. "undo since last tab switch"), and GUI resize + in-session tab navigation is a sufficiently niche combination that we're treating this as a known limitation rather than a blocking fix.

@simeji
simeji merged commit 299076f into master Mar 28, 2026
2 checks passed
@simeji
simeji deleted the feature/size-and-tab-commands branch March 28, 2026 15:38
@simeji simeji mentioned this pull request Mar 28, 2026
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.

1 participant