mirror of
https://github.com/neovim/neovim.git
synced 2025-09-19 17:58:18 +00:00
api: nvim_get_mode()
Asynchronous API functions are served immediately, which means pending input could change the state of Nvim shortly after an async API function result is returned. nvim_get_mode() is different: - If RPCs are known to be blocked, it responds immediately (without flushing the input/event queue) - else it is handled just-in-time before waiting for input, after pending input was processed. This makes the result more reliable (but not perfect). Internally this is handled as a special case, but _semantically_ nothing has changed: API users never know when input flushes, so this internal special-case doesn't violate that. As far as API users are concerned, nvim_get_mode() is just another asynchronous API function. In all cases nvim_get_mode() never blocks for more than the time it takes to flush the input/event queue (~µs). Note: This doesn't address #6166; nvim_get_mode() will provoke #6166 if e.g. `d` is operator-pending. Closes #6159
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "nvim/vim.h"
|
||||
#include "nvim/log.h"
|
||||
#include "nvim/ascii.h"
|
||||
#include "nvim/normal.h"
|
||||
#include "nvim/buffer.h"
|
||||
@@ -541,7 +542,7 @@ static bool normal_handle_special_visual_command(NormalState *s)
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool normal_need_aditional_char(NormalState *s)
|
||||
static bool normal_need_additional_char(NormalState *s)
|
||||
{
|
||||
int flags = nv_cmds[s->idx].cmd_flags;
|
||||
bool pending_op = s->oa.op_type != OP_NOP;
|
||||
@@ -1083,7 +1084,7 @@ static int normal_execute(VimState *state, int key)
|
||||
}
|
||||
|
||||
// Get an additional character if we need one.
|
||||
if (normal_need_aditional_char(s)) {
|
||||
if (normal_need_additional_char(s)) {
|
||||
normal_get_additional_char(s);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user