rcarriga/nvim-notify

Displaying notifications on startup does not work when opening multiple files in split windows (nvim -o / nvim -O...)

TheEpic-dev opened this issue · 5 comments

Hey! Thanks for this plugin. It looks great, but I think I found a small bug. I don't believe the issue is with my configuration, as I seem to be able to reproduce it with the default config.

Reproducing the bug

To reproduce (please adjust paths and commands accordingly if necessary, e.g. non-POSIX system):

mkdir /tmp/notify-test/
nvim /tmp/notify-test/example.lua

Copy/paste the contents into the file:

vim.notify = require("notify") -- I presume you already have it installed :)
vim.notify("Oh, no!")

After saving and exiting, open multiple files in a vertical split with this minimal config:

# note that -o also seems to reproduce the bug.
nvim -u /tmp/notify-test/example.lua -O /tmp/randomfile /tmp/notify-test/example.lua

Actual behavior

This opens /tmp/randomfile as a single window, and the notification displays the contents of the file /tmp/notify-test/example.lua.

nvimbug

Expected behavior

Neovim should open the two files side-by-side in a vertical split, and the notification should display "Oh, no!"

Tech specs

OS: Arch Linux
nvim: 0.9.1-1 (latest version in the Arch repos)
nvim-notify: ea9c8ce, tagged v3.12.0

Conclusions

  • I think this is a new bug report from looking at the open issues.
  • Pretty sure I am running all the latest (stable) versions of everything. I did not test e.g. nightly builds, or look into other branches (if there are any).
  • This isn't a very high priority bug (to me) as it mostly works, but I sometimes do call notifications on startup while testing some code I work on, so don't let it interrupt your summer :D

I see the same thing with nvim -d (vimdiff). I am on nightly and do not have the issue with the plugin disabled.

I have the same issue on NVIM v0.9.1 release.

I originally filed the bug here but I've closed it since it duplicates this bug.

+1

This seems to be a neovim internal bug with opening a floating window during startup while there are multiple split windows. A similar effect can be seen by just adding the following to your init.lua

local buf = vim.api.nvim_create_buf(false, true)
vim.api.nvim_buf_set_name(buf, "test")
vim.api.nvim_buf_set_lines(buf, 0, -1, false, { "Hello, world!" })
vim.api.nvim_open_win(buf, true, {
  relative = "editor",
  width = 40,
  height = 10,
  row = 10,
  col = 10,
  style = "minimal",
  border = "single",
})

I've added a workaround so please let me know if the issue is solved 😄

Beautiful, deferring the call seems to fix it for me (at least with splits, I didn't test the diff view). Thanks 😃

I think this can be closed.

FYI: Tests are failing since b8e0a01 because nvim.notify() has no longer has return value in tests.

-> PR #227