fix(init): skip WinNew split handler before VimEnter

Problem: running `nvim oil-ssh://host/` from the command line sometimes
emits "Oil split could not find parent window" immediately on startup.
The `WinNew` autocmd that transfers oil window vars to new splits fires
during startup before `BufEnter` has set `oil_did_enter` on any window,
so the parent search finds nothing and warns.

Solution: guard the callback with `vim.v.vim_did_enter ~= 1` so it is
silently skipped during the pre-`VimEnter` startup phase. After
`VimEnter` the split-transfer logic runs unchanged. `vim_did_enter` is
already used in `setup()` for the same startup-completion check.

Based on: stevearc/oil.nvim#325
This commit is contained in:
Barrett Ruth 2026-03-18 13:23:19 -04:00
parent e387a57c0e
commit 36c07875d2
Signed by: barrett
GPG key ID: A6C96C9349D2FC81
2 changed files with 4 additions and 1 deletions

View file

@ -54,7 +54,7 @@ issues against this fork.
| [#298](https://github.com/stevearc/oil.nvim/issues/298) | Open float on neovim directory startup | open | | [#298](https://github.com/stevearc/oil.nvim/issues/298) | Open float on neovim directory startup | open |
| [#302](https://github.com/stevearc/oil.nvim/issues/302) | `buflisted=true` after jumplist nav | fixed ([#71](https://github.com/barrettruth/canola.nvim/pull/71)) | | [#302](https://github.com/stevearc/oil.nvim/issues/302) | `buflisted=true` after jumplist nav | fixed ([#71](https://github.com/barrettruth/canola.nvim/pull/71)) |
| [#303](https://github.com/stevearc/oil.nvim/issues/303) | Preview in float window mode | fixed — upstream [#403](https://github.com/stevearc/oil.nvim/pull/403), `config.float.preview_split` | | [#303](https://github.com/stevearc/oil.nvim/issues/303) | Preview in float window mode | fixed — upstream [#403](https://github.com/stevearc/oil.nvim/pull/403), `config.float.preview_split` |
| [#325](https://github.com/stevearc/oil.nvim/issues/325) | oil-ssh error from command line | consolidated into [#164](https://github.com/barrettruth/canola.nvim/issues/164) | | [#325](https://github.com/stevearc/oil.nvim/issues/325) | oil-ssh error from command line | fixed |
| [#330](https://github.com/stevearc/oil.nvim/issues/330) | Telescope opens file in oil float | not actionable — cross-plugin, no repro | | [#330](https://github.com/stevearc/oil.nvim/issues/330) | Telescope opens file in oil float | not actionable — cross-plugin, no repro |
| [#332](https://github.com/stevearc/oil.nvim/issues/332) | Buffer not fixed to floating window | not actionable — cannot reproduce | | [#332](https://github.com/stevearc/oil.nvim/issues/332) | Buffer not fixed to floating window | not actionable — cannot reproduce |
| [#335](https://github.com/stevearc/oil.nvim/issues/335) | Disable editing outside root dir | not actionable — confirmation prompt and `delete_to_trash` already cover accidental deletion | | [#335](https://github.com/stevearc/oil.nvim/issues/335) | Disable editing outside root dir | not actionable — confirmation prompt and `delete_to_trash` already cover accidental deletion |

View file

@ -1566,6 +1566,9 @@ M.setup = function(opts)
pattern = '*', pattern = '*',
nested = true, nested = true,
callback = function(params) callback = function(params)
if vim.v.vim_did_enter ~= 1 then
return
end
local util = require('oil.util') local util = require('oil.util')
if not util.is_oil_bufnr(params.buf) or vim.w.oil_did_enter then if not util.is_oil_bufnr(params.buf) or vim.w.oil_did_enter then
return return