folke / noice.nvim

💥 Highly experimental plugin that completely replaces the UI for messages, cmdline and the popupmenu.
Apache License 2.0
4.45k stars 105 forks source link

bug: Vimscript function must not be called in a fast event context #997

Closed b0o closed 3 hours ago

b0o commented 3 hours ago

Did you check docs and existing issues?

Neovim version (nvim -v)

NVIM v0.11.0-dev-1161+g6ef80eb42c

Operating system/version

Arch Linux 6.11.7

Describe the bug

Run :echo "test" or any other command which causes Noice to print a message.

An error happened while handling a ui event
....local/share/nvim/lazy/nui.nvim/lua/nui/text/init.lua:31: E5560: Vimscript function must not be called in a fast event context

stack traceback:
    ...local/share/nvim/lazy/noice.nvim/lua/noice/util/call.lua:144: in function <...local/share/nvim/lazy/noice.nvim/lua/noice/util/call.lua:143>
    [C]: in function 'strlen'
    ....local/share/nvim/lazy/nui.nvim/lua/nui/text/init.lua:31: in function 'set'
    ....local/share/nvim/lazy/nui.nvim/lua/nui/text/init.lua:18: in function 'init'
    .../.local/share/nvim/lazy/nui.nvim/lua/nui/object/init.lua:132: in function 'NuiText'
    ....local/share/nvim/lazy/nui.nvim/lua/nui/line/init.lua:20: in function '_append'
    ...ocal/share/nvim/lazy/noice.nvim/lua/noice/text/block.lua:186: in function 'append'
    ...ocal/share/nvim/lazy/noice.nvim/lua/noice/text/block.lua:129: in function 'set'
    ...y/.local/share/nvim/lazy/noice.nvim/lua/noice/ui/msg.lua:108: in function 'handler'
    .../.local/share/nvim/lazy/noice.nvim/lua/noice/ui/init.lua:190: in function <.../.local/share/nvim/lazy/noice.nvim/lua/noice/ui/init.lua:189>
    [C]: in function 'xpcall'
    ...local/share/nvim/lazy/noice.nvim/lua/noice/util/call.lua:149: in function 'safe_handle'
    .../.local/share/nvim/lazy/noice.nvim/lua/noice/ui/init.lua:95: in function <.../.local/share/nvim/lazy/noice.nvim/lua/noice/ui/init.lua:77>
    [C]: in function 'nvim_out_write'
    vim/_editor.lua: in function 'print'
    [string ":lua"]:1: in main chunk

This issue started happening as of https://github.com/neovim/neovim/commit/de48fbbd5f8800bd7f1909a6fb41e53e871cf74c (https://github.com/neovim/neovim/pull/27874), which changes vim.ui_attach message callbacks to execute in fast context.

folke commented 3 hours ago

Should be fixed now. msg_show events are no longer processed realtime, so this might have other side-effects. Let me know if you notice anything else broken.

Thank you for reporting!

b0o commented 2 hours ago

Thanks for the quick fix! One issue now is if you try searching with / for a pattern which doesn't exist in the buffer, the "not found" message isn't printed and the search bar gets stuck until you do something to trigger a redraw.

b0o commented 2 hours ago

Also a similar thing happens with a mapping like :confirm qall with unsaved changes.

folke commented 1 hour ago

Yeah indeed. Some things are broken now... Not sure how I can fix that confirm message.

The searching thing works for me with Snacks.notifier. nvim-notify has some issues with redraw.

folke commented 1 hour ago

Opened a tracking issue. Feel free to add anything else you find is broken...