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

nvim_command hangs when in 'f' mode #13626

Closed
mkeeter opened this issue Dec 28, 2020 · 7 comments
Closed

nvim_command hangs when in 'f' mode #13626

mkeeter opened this issue Dec 28, 2020 · 7 comments
Labels
api libnvim, Nvim RPC API closed:wontfix current behavior is by design, and change is not desired rpc

Comments

@mkeeter
Copy link

mkeeter commented Dec 28, 2020

  • nvim --version: NVIM v0.4.4, Build type: Release, LuaJIT 2.0.5
  • vim -u DEFAULTS (version: ) behaves differently? N/A, this is an RPC issue
  • Operating system/version: macOS 10.13
  • Terminal name/version: iTerm 2, Build 3.3.12beta3, but this is not terminal-dependent
  • $TERM: xterm-256color, but this is not terminal-dependent

Steps to reproduce using nvim -u NORC

NVIM_LISTEN_ADDRESS=/tmp/nvim nvim -u NORC

In the Neovim window, press f to enter find mode, but do not type a second character.

In a separate Python shell, with pynvim installed:

from pynvim import attach
nvim = attach('socket', path='/tmp/nvim')
nvim.command('echo "HI"')

Actual behaviour

This will hang the Python shell until you Ctrl-C it, or type another character in the Neovim TUI.

I provided reproduction steps using the Python API, but this is particularly problematic when building a UI that embeds Neovim: it means that you can't ever use blocking nvim_command calls, because they will deadlock if an f search is pending.

Expected behaviour

nvim_command is executed, HI appears in the status line, and the Python shell does not block.

@mkeeter mkeeter added the bug issues reporting wrong behavior label Dec 28, 2020
@jamessan
Copy link
Member

jamessan commented Dec 30, 2020

nvim_get_mode() can be used to determine if nvim is blocking.

See also :help api-fast.

@mkeeter
Copy link
Author

mkeeter commented Dec 30, 2020

Thanks, this lets me work around the issue!

It still seems fundamentally awkward – for example, does this mean it's impossible to resize a window while waiting for the character after f?

@bfredl
Copy link
Member

bfredl commented Dec 30, 2020

well, you don't need to block the process just because you are waiting for a responce from neovim. In the case of pynvim it uses two threads (because noone has written the "glue" to integrate glib eventloop with asyncio in a single thread), but you could also use whatever async/coroutine abstraction of your language (assuming zig in you case :).

@justinmk justinmk added api libnvim, Nvim RPC API enhancement feature request bug issues reporting wrong behavior and removed bug issues reporting wrong behavior enhancement feature request labels Jul 3, 2021
@justinmk
Copy link
Member

justinmk commented Jul 3, 2021

Is this really a bug or an enhancement? It is expected Nvim in a "pending" state is blocking (except for :help api-fast RPC requests). We did have plans to make Nvim non-blocking under more scenarios.

related #7142

@mkeeter
Copy link
Author

mkeeter commented Jul 3, 2021

I have no real opinion on whether this should be classified as a bug or an enhancement, just found it to be a surprising footgun when writing a GUI!

Also, I just noticed that Vim and Neovim differ, at least in their TUIs: in Vim, if I type f then resize the window, it clears the pending find and resizes right away; in Neovim, it leaves the f staged and doesn't redraw.

@justinmk
Copy link
Member

justinmk commented Jul 3, 2021

in Vim, if I type f then resize the window, it clears the pending find and resizes right away; in Neovim, it leaves the f staged and doesn't redraw.

Clearing the pending f would be disruptive because any RPC would interrupt a user's pending command. #5685

@justinmk justinmk added closed:wontfix current behavior is by design, and change is not desired rpc and removed bug issues reporting wrong behavior labels Apr 23, 2022
@justinmk
Copy link
Member

This is by design.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api libnvim, Nvim RPC API closed:wontfix current behavior is by design, and change is not desired rpc
Projects
None yet
Development

No branches or pull requests

4 participants