Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
TheEpic-dev opened this issue Jul 1, 2023 · 5 comments

Comments

@TheEpic-dev
Copy link

TheEpic-dev commented Jul 1, 2023

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
@rmccord7
Copy link

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

@squk
Copy link

squk commented Aug 30, 2023

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

rcarriga added a commit that referenced this issue Sep 10, 2023
@rcarriga
Copy link
Owner

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 😄

@TheEpic-dev
Copy link
Author

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.

@wookayin
Copy link
Contributor

wookayin commented Oct 10, 2023

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

-> PR #227

wookayin added a commit to wookayin/nvim-notify that referenced this issue Oct 10, 2023
The `vim_starting` workaround in rcarriga#209 makes test failing, because
`notify(...)` no longers return any value when `vim.schedule`-ed.
In the headless mode (under which plenary unit tests are running),
we do not need to defer the execution. This should fix all the tests
that were failing.
njhoffman pushed a commit to njhoffman/nvim-notify that referenced this issue Dec 25, 2023
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

No branches or pull requests

5 participants