Skip to content

feat: toggle layout, welcome page improvements, stale buffer fixes#307

Merged
esmuellert merged 8 commits intomainfrom
dev
Mar 4, 2026
Merged

feat: toggle layout, welcome page improvements, stale buffer fixes#307
esmuellert merged 8 commits intomainfrom
dev

Conversation

@esmuellert
Copy link
Owner

@esmuellert esmuellert commented Mar 4, 2026

Summary

Toggle between inline and side-by-side layout (t key)

Press t in any diff view to toggle between side-by-side and inline layout. The current file is re-rendered in the new layout automatically. Works in explorer, history, and standalone modes.

  • toggle.lua: Orchestrates layout switch (normalize windows → rerender current file)
  • Uses existing single_pane mechanism and rerender_current() to replay file selection
  • Conflict mode blocks toggle (not applicable)
  • Configurable: keymaps.view.toggle_layout = "t"

Closes #292
Closes #302
Closes the runtime toggle aspect of #146.

Welcome page improvements

  • Fixed flicker: guard against re-creating welcome buffer on every refresh cycle
  • Fixed stale selection highlight persisting after welcome page shown
  • Fixed missing welcome module require (regression from toggle refactoring)

Stale buffer fix improvements

  • Cross-platform git helpers in all test files (fixes Windows CI)
  • Double-quoted commit messages for Windows cmd.exe compatibility

Code cleanup

  • Removed display_state / diff_config abstractions (toggle works purely through existing session fields)
  • Removed dead code: reset_diff_panes, show_single_file_preview, current_layout wrapper
  • Renamed for consistency: rerender_current_sourcererender_current_file
  • Toggle always commits layout change (no rollback desync)

Documentation

  • README: toggle feature in features list + keymaps config
  • vimdoc: new codediff-toggle-layout section
  • Tags regenerated

Testing

  • Layout toggle test suite (layout_toggle_spec.lua)
  • All existing tests pass (Linux + Windows CI)

esmuellert and others added 6 commits March 4, 2026 15:03
Add ability to toggle diff layout while a session is open. Uses the
existing single_pane mechanism for A/D files and rerender_current()
to replay the current file selection in the new layout.

- toggle.lua: orchestrates layout switch (normalize windows, rerender)
- explorer/history: rerender_current() + current_selection + opts.force
- side_by_side/inline_view: layout identity guards, window validity guards
- keymaps: fresh buffer refs at execution time (stale closure fix)
- lifecycle: get_layout/update_layout accessors

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…sistency

- Remove display_state, diff_config, and their helpers (set_display_state,
  copy_session_config, build_single_file_state) — toggle works purely
  through existing session fields + rerender_current()
- Remove reset_diff_panes (dead code — unreachable fallback)
- Rename show_placeholder → reset_diff_panes (removed)
- Rename rerender_current_source → rerender_current_file
- Remove show_single_file_preview (dead code, no callers)
- Remove current_layout private wrapper (inlined)
- Change default toggle keymap from gl to t
- Fix toggle rollback: always commit layout change, no desync

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The toggle refactoring accidentally removed the eager require for
codediff.ui.welcome at the top of refresh.lua, causing welcome
page to never show (nil reference error on every refresh cycle).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The selected_path/selected_group closure variables in explorer
render.lua persisted after welcome page was shown, causing stale
highlight on matching file entries. Added clear_selection() method
on explorer object, called from clear_current_file() in refresh.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- README: add toggle_layout = 't' to keymaps config, add toggle
  feature to features list
- vimdoc: add codediff-toggle-layout section, add toggle_layout
  to keymaps config example
- tags: regenerated

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- macOS: resolve symlinks in path comparison (/var vs /private/var)
- Windows: use double quotes in all git commit messages (single
  quotes are literal on cmd.exe)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@esmuellert esmuellert force-pushed the dev branch 2 times, most recently from d96e9bc to 8a6eb94 Compare March 4, 2026 22:57
Root cause: vim.fn.system (synchronous) called inside vim.wait's
condition function blocks the event loop, preventing vim.system's
async callbacks from completing. On Windows where git is slower,
the async chain (git apply → callback → refresh → status → render)
never finishes.

Fix: use pure event-loop spin (vim.wait with return false) for all
hunk operation tests (stage, unstage, discard) to let the full async
chain complete without blocking.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@esmuellert esmuellert merged commit 46a1b8e into main Mar 4, 2026
13 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.

feat: add ability to toggle layouts

1 participant