Skip to content

feat: resize side/diff panel width#18

Merged
Blankeos merged 4 commits into
Blankeos:mainfrom
fcmiranda:feature/expand-shrink
May 31, 2026
Merged

feat: resize side/diff panel width#18
Blankeos merged 4 commits into
Blankeos:mainfrom
fcmiranda:feature/expand-shrink

Conversation

@fcmiranda
Copy link
Copy Markdown
Contributor

@fcmiranda fcmiranda commented May 19, 2026

Summary

Adds orientation-aware side-panel resize keybindings. At both ratio extremes the hidden panel is fully removed from the layout — no leftover border or empty rect.

ezgif-3c1d783226675521.mp4

Landscape (side left, diff right)

Key Action
Alt+H Shrink side panel by 5%
Alt+L Expand side panel by 5%
Alt+K Side panel full — diff hidden
Alt+J Diff panel full — side hidden
Alt+R Reset to configured default

Portrait / vertical stack (side top, diff bottom)

Key Action
Alt+H Shrink side panel by 5%
Alt+L Expand side panel by 5%
Alt+K Diff panel full — side hidden
Alt+J Side panel full — diff hidden
Alt+R Reset to configured default

Implementation

  • keybindings.rs — added shrinkSidePanel (<a-h>), expandSidePanel (<a-l>), sidePanelFull (<a-k>), mainPanelFull (<a-j>), resetSidePanel (<a-r>) to UniversalKeybinding; all user-overridable via config
  • layout.rs — portrait branch gets symmetric early-returns at ratio ≤ 0.0 and ≥ 1.0 (mirrors existing landscape short-circuits); removed height/2 cap so stepping is unrestricted; portrait collapsed-panel height fixed to 1 to prevent the active-panel height jumping backwards when crossing the 21-row threshold; landscape panel sizing extracted into split_side_panels()
  • mod.rs — resize handler detects portrait mode at dispatch time and swaps Alt+K/Alt+J semantics accordingly; step behaviour is identical in both orientations
  • views.rs — guards main panel rendering behind fl.main_panel.width > 0 so it is skipped when the side panel is fully expanded

Tested

Kitty, Zed

@Blankeos
Copy link
Copy Markdown
Owner

I can't reproduce this with any of my terminals (Zed, Wezterm). ctrl+shift+H or ctrl+shift+L doesn't seem to work with any.

@fcmiranda fcmiranda force-pushed the feature/expand-shrink branch from e2ed558 to a2a72b0 Compare May 20, 2026 09:44
- Alt+h/l: shrink/expand side panel by 5% steps
- Alt+H: jump main (diff) panel to full width
- Alt+L: jump side panel to full width
- Alt+r: reset side panel to configured default width
- Panel can now reach both borders (0%–100%)
- Side panel fully collapsed hides side panels entirely
- Side panel fully expanded hides diff panel entirely (no border artifact)
- Fix parse_key: <a-X> with uppercase X now includes SHIFT modifier
- Fix parse_key: <c-s-X> Ctrl+Shift combo parsed before <c-X>
@fcmiranda fcmiranda force-pushed the feature/expand-shrink branch from a2a72b0 to f6ce727 Compare May 20, 2026 09:47
@fcmiranda fcmiranda changed the title feat: add Ctrl+Shift+H/L keybindings to resize side panel width feat: resize side/diff panel width May 20, 2026
@fcmiranda
Copy link
Copy Markdown
Contributor Author

@Blankeos Sorry about that, can you check now? I have made some improvements and I tested on kitty and zed. However, I could'n test on Wezterm yet.

@fcmiranda
Copy link
Copy Markdown
Contributor Author

Hi @Blankeos! Have you check the last change i made into this PR? Let me know what you think :)

@Blankeos
Copy link
Copy Markdown
Owner

Hi sorry! Had to go offline a lot this week.

Btw by chance... Have you not tried to do the shift- and shift+ hotkeys yet? This was from the original lazygit, which I already implemented, it might solve your gripes on changing panel sizing. The existing UX is pretty usable for me.

But I'll still merge this since...

  • ✅ I like alt-h and alt-k + alt-r I think.
  • Though seems like alt-j and alt-k is just making it "full width" (which is what shift - cycles to the first time).
  • I am afraid it occupies too many shortcut keys too early though. (Future anxiety if there's better shortcuts, it can't take those anymore)

I'm merging it, but I'll go ahead and fix these bugs Codex found, before I release:

I found regressions on feature/expand-shrink compared to origin/main.

Findings

# I think this one needs fixing
  1. High: side-panel-full can crash or render the command log off-
     screen.
     When side_panel_ratio reaches 1.0, layout returns main_panel:
     Rect::default() in src/gui/layout.rs:218. Rendering skips the
     main panel, but render_command_log still computes placement
     from fl.main_panel.height in src/gui/views.rs:718. With the
     default command log enabled and non-empty, 0 - log_height - 1
     underflows in debug builds and wraps in release builds.

# I dont think this needs fixing. Probably just an accepted limitation.
  2. Medium: making the side panel full does not update focus.
     The new Alt full-panel handlers only mutate side_panel_ratio in
     src/gui/mod.rs:1527. If the diff was focused and the user
     expands the side panel to full width, the diff disappears but
     diff_focused remains true. Subsequent keys and mouse wheel
     events still route to hidden diff behavior, including the
     scroll path at src/gui/mod.rs:4483. The visible sidebar is not
     naturally controllable until the user explicitly changes focus.

@Blankeos Blankeos merged commit 1294716 into Blankeos:main May 31, 2026
5 checks passed
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.

2 participants