Skip to content

fix(actions): stopinsert before swtich buf#2684

Merged
phanen merged 1 commit intomainfrom
stopinsert-before-switchbuf
Apr 19, 2026
Merged

fix(actions): stopinsert before swtich buf#2684
phanen merged 1 commit intomainfrom
stopinsert-before-switchbuf

Conversation

@phanen
Copy link
Copy Markdown
Collaborator

@phanen phanen commented Apr 19, 2026

We previous rely on "switch from terminal buffer to normal buffer" to
help us to resume to normal mode, but action set_buf to switch to a
terminal buffer again before the modechange

#2681 (comment)

Fix #2681

Summary by CodeRabbit

  • Bug Fixes
    • Fixed an issue where insert mode was not properly exited when switching buffers, ensuring smoother buffer transitions.

We previous rely on "switch from terminal buffer to normal buffer" to
help us to resume to normal mode, but action set_buf to switch to a
terminal buffer again before the modechange

#2681 (comment)
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 19, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: eeb63257-dfa2-4d4b-b25a-cd21eb9d6e7d

📥 Commits

Reviewing files that changed from the base of the PR and between cebf888 and d1076b3.

📒 Files selected for processing (1)
  • lua/fzf-lua/actions.lua

📝 Walkthrough

Walkthrough

Added vim.cmd.stopinsert() inside the set_buf() helper function to ensure insert mode is exited before switching buffers. This addresses an issue where terminal buffers were being unintentionally closed when selected through the fzf-lua buffers picker.

Changes

Cohort / File(s) Summary
Insert Mode Exit
lua/fzf-lua/actions.lua
Added explicit vim.cmd.stopinsert() call inside set_buf() after bufhidden adjustment to properly exit insert mode during buffer replacement operations.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • fix: resume any "normal"-like mode #2682: Modifies when/where vim.cmd.stopinsert() is invoked to exit insert/terminal mode during buffer/window switches, addressing similar control flow concerns.
  • actions fixes #2666: Updates lua/fzf-lua/actions.lua's set_buf() logic for buffer-replacement and bufhidden handling, directly related to this change's context.

Poem

🐰 A tiny tweak, a mode to cease,
Insert mode exits for terminal peace,
No more buffers lost in the fray,
Switching clean in the fzf way!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(actions): stopinsert before swtich buf' directly describes the main change: adding stopinsert before switching buffers to fix the terminal buffer closure issue.
Linked Issues check ✅ Passed The PR correctly implements the fix for issue #2681 by calling stopinsert before switching buffers, preventing the race condition that caused terminal buffers to close.
Out of Scope Changes check ✅ Passed The change is focused and directly addresses the linked issue #2681 with no extraneous modifications beyond the necessary stopinsert call.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch stopinsert-before-switchbuf

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@phanen phanen merged commit 8342463 into main Apr 19, 2026
17 of 18 checks passed
@phanen phanen deleted the stopinsert-before-switchbuf branch April 19, 2026 04:38
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.

Bug: FzfLua buffers closes/deletes terminal buffers

1 participant