Skip to content

Close views with q everywhere and swap views in one tab - #23

Merged
CoreyKaylor merged 2 commits into
mainfrom
close-and-reuse-tabs
Nov 5, 2026
Merged

CoreyKaylor merged 2 commits into
mainfrom
close-and-reuse-tabs

Conversation

@CoreyKaylor

Copy link
Copy Markdown
Owner

Fixes #22 and fixes #20.

Closing (#22)

The X in the reporter's screenshot is Neovim's default tabline close button. It appears only with the stock tabline and two or more tabs, so it isn't a dependable way to close a view, and nothing in DiffBandit pointed to q.

  • q in the commit panel now closes the whole view (diff, merge resolver, or standalone panel). Before, it only hid the panel inside a diff, while q in the diff panes closed everything.
  • New :DiffBanditClose command and require("diffbandit").close().
  • gzp shows or hides the panel in 2-way diffs, from the panes or the panel, matching merge. Hiding a focused panel returns focus to a diff pane.
  • The diff pane's close key is configurable: navigation.close_key (default q, false disables it).
  • Closing a view keeps an unfinished commit message. It's saved per repository and restored by the next panel opened there; committing clears it. Amend and read-only review panels never save drafts.
  • Closed sessions and standalone panels delete their panel buffers. Before, a modified commit buffer stayed loaded and made :qa fail with E37.
  • The panel's internal hide (panel.close) only hides now. It used to close the whole session in review mode, but q calls the host's close directly.

One tab when switching files (#20)

Moving the panel selection between a merge conflict and a changed file started a new host in a new tab and left the old one open. Now the new view opens first, then the old one closes. If the new view fails to open, the old one stays. Unsaved edits in a merge result are kept, because closing hides that buffer rather than deleting it.

Tests

  • 20_git_merge: changed file → conflict → changed file keeps the tab count and disposes the old views. Also covers gzp in both directions, q from the panel, and saving, restoring and clearing the draft.
  • 15_running: :DiffBanditClose closes a session tab and returns to the original tab, closes a standalone panel, and does nothing when no view is open.
  • 25_launcher: outside launcher mode, q in the panel closes the tab; in launcher mode it still quits nvim.

nvim --headless -u tests/run.lua passes.

q in the commit panel now closes the whole view, the same as q in the
diff panes, and :DiffBanditClose does it from the command line. gzp
toggles the panel in 2-way diffs, and the session close key is
configurable via navigation.close_key.

Closing a view saves an unfinished commit message for the repository;
the next panel opened there restores it, and committing clears it.
Closed hosts delete their panel buffers so a modified commit buffer no
longer blocks :qa with E37.

Moving the panel selection between a merge conflict and a changed file
now closes the previous view instead of leaving its tab behind.

Fixes #20
Fixes #22
@CoreyKaylor
CoreyKaylor merged commit 48ef45c into main Nov 5, 2026
1 check passed
@CoreyKaylor
CoreyKaylor deleted the close-and-reuse-tabs branch November 5, 2026 01:26
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.

Is there a close command? New scratch tab is opened when navigating between merge conflict and changes nodes

1 participant