Skip to content

fix(files): ensure BufWinEnter after :edit <dir>#2467

Open
abeldekat wants to merge 1 commit into
nvim-mini:mainfrom
abeldekat:fix_files_for_clue
Open

fix(files): ensure BufWinEnter after :edit <dir>#2467
abeldekat wants to merge 1 commit into
nvim-mini:mainfrom
abeldekat:fix_files_for_clue

Conversation

@abeldekat

Copy link
Copy Markdown
Member

Details:

  • By default, 'mini.files' replaces 'netrw'. When a directory is opened with :edit <dir>, and the explorer is closed without opening a file, 'mini.files' shows the alternate buffer if present. If there is no alternate buffer, a new buffer is created. Event BufWinEnter needs to fire in order for mini.clue to attach.

Resolve #2466

@echasnovski

Copy link
Copy Markdown
Member

Thanks for the PR!

I can indeed reproduce the issue, however the solution is not quite right. Usually if there is a problem with some event not triggering, two most probable causes are: 1) it is executed inside an autocommand without nested = true; 2) there is an explicit/intentional 'eventignore'. The first one is the culprit in this case, as nvim_buf_delete() is executed inside a callback (H.track_dir_edit) for BufEnter function. Modifying the autocommand creation to include nested = true fixes the issue here.

Also note, that merging this will have to wait until 0.18.0 release.

@abeldekat abeldekat force-pushed the fix_files_for_clue branch from ad3f9ab to 20b6b75 Compare June 17, 2026 12:21
@abeldekat

Copy link
Copy Markdown
Member Author

The first one is the culprit in this case, as nvim_buf_delete() is executed inside a callback (H.track_dir_edit) for BufEnter function.

Initially I worried that nested would be propagated to the code in MiniFiles.open causing side-effects. I missed that in H.track_dir_edit it is MiniFiles.open itself that is scheduled. Thanks!

Comment thread lua/mini/files.lua Outdated
Details:
- By default, 'mini.files' replaces 'netrw'. When a directory is opened
  with `:edit <dir>`, and the explorer is closed without opening a
  file, 'mini.files' shows the alternate buffer if present.
  If there is no alternate buffer, a new buffer is created. Event
  `BufWinEnter` needs to fire in order for `mini.clue` to attach.

Resolve nvim-mini#2466
@abeldekat abeldekat force-pushed the fix_files_for_clue branch from 20b6b75 to fa9600f Compare June 18, 2026 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When closing mini.files after :edit <dir> clues sometimes don't work

2 participants