Skip to content

fix(#3187): prevent closing the last non-floating window when deleting files#3282

Merged
alex-courtis merged 1 commit intonvim-tree:masterfrom
Fidelxyz:fix-3187
Feb 27, 2026
Merged

fix(#3187): prevent closing the last non-floating window when deleting files#3282
alex-courtis merged 1 commit intonvim-tree:masterfrom
Fidelxyz:fix-3187

Conversation

@Fidelxyz
Copy link
Contributor

Fixes #3187

Copilot AI review requested due to automatic review settings February 27, 2026 01:07
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug where nvim-tree would throw an E444: Cannot close last window error when deleting a file that's currently open, in configurations where multiple floating windows exist (such as from the Snacks plugin). The previous logic counted total windows, which failed when floating windows were present. The fix correctly counts only non-floating windows to determine when it's safe to close windows.

Changes:

  • Updated window closing logic to count non-floating windows instead of total windows
  • Prevents closing the last non-floating window when nvim-tree is in floating mode

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Fidelxyz
Copy link
Contributor Author

Ouch, sorry I did't realized I enabled AI reviews... Turing it off.

Copy link
Member

@alex-courtis alex-courtis left a comment

Choose a reason for hiding this comment

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

Many thanks for dealing with this one; that horrible < 3 has been hanging around for too long.

Code looks safe and clear.

Test ok:

  • issue test case
    • float enabled
    • float disabled
    • actions config commented
  • default config

@alex-courtis alex-courtis merged commit 018a078 into nvim-tree:master Feb 27, 2026
7 of 8 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.

[Floating] Cannot close last window

3 participants