aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2019-06-30 16:03:58 +0200
committerGitHub <noreply@github.com>2019-06-30 16:03:58 +0200
commit10a533e9d41ad8917c17e96cf696fcea4b07374f (patch)
tree69bcc294d1a956856578e9dfb6d87271b6057729 /src/nvim/api
parent3b504e7c8d20bb41ef6b6f95e46527766438046a (diff)
parent99f24dfbed84cea24fc1d8bb80ab10a2dd3eca0b (diff)
downloadrneovim-10a533e9d41ad8917c17e96cf696fcea4b07374f.tar.gz
rneovim-10a533e9d41ad8917c17e96cf696fcea4b07374f.tar.bz2
rneovim-10a533e9d41ad8917c17e96cf696fcea4b07374f.zip
Merge pull request #10316 from bfredl/cb_safety
luv callbacks: throw error on deferred methods instead of crashing
Diffstat (limited to 'src/nvim/api')
-rw-r--r--src/nvim/api/private/dispatch.h6
-rw-r--r--src/nvim/api/vim.c10
2 files changed, 9 insertions, 7 deletions
diff --git a/src/nvim/api/private/dispatch.h b/src/nvim/api/private/dispatch.h
index 39aabd708a..bad5a13934 100644
--- a/src/nvim/api/private/dispatch.h
+++ b/src/nvim/api/private/dispatch.h
@@ -11,8 +11,10 @@ typedef Object (*ApiDispatchWrapper)(uint64_t channel_id,
/// functions of this type.
typedef struct {
ApiDispatchWrapper fn;
- bool async; // function is always safe to run immediately instead of being
- // put in a request queue for handling when nvim waits for input.
+ bool fast; // Function is safe to be executed immediately while running the
+ // uv loop (the loop is run very frequently due to breakcheck).
+ // If "fast" is false, the function is deferred, i e the call will
+ // be put in the event queue, for safe handling later.
} MsgpackRpcRequestHandler;
#ifdef INCLUDE_GENERATED_DECLARATIONS
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index 72eb68b650..8e5650633a 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -209,7 +209,7 @@ void nvim_feedkeys(String keys, String mode, Boolean escape_csi)
/// @return Number of bytes actually written (can be fewer than
/// requested if the buffer becomes full).
Integer nvim_input(String keys)
- FUNC_API_SINCE(1) FUNC_API_ASYNC
+ FUNC_API_SINCE(1) FUNC_API_FAST
{
return (Integer)input_enqueue(keys);
}
@@ -238,7 +238,7 @@ Integer nvim_input(String keys)
/// @param[out] err Error details, if any
void nvim_input_mouse(String button, String action, String modifier,
Integer grid, Integer row, Integer col, Error *err)
- FUNC_API_SINCE(6) FUNC_API_ASYNC
+ FUNC_API_SINCE(6) FUNC_API_FAST
{
if (button.data == NULL || action.data == NULL) {
goto error;
@@ -1256,7 +1256,7 @@ Dictionary nvim_get_color_map(void)
///
/// @returns Dictionary { "mode": String, "blocking": Boolean }
Dictionary nvim_get_mode(void)
- FUNC_API_SINCE(2) FUNC_API_ASYNC
+ FUNC_API_SINCE(2) FUNC_API_FAST
{
Dictionary rv = ARRAY_DICT_INIT;
char *modestr = get_mode();
@@ -1342,7 +1342,7 @@ Dictionary nvim_get_commands(Dictionary opts, Error *err)
///
/// @returns 2-tuple [{channel-id}, {api-metadata}]
Array nvim_get_api_info(uint64_t channel_id)
- FUNC_API_SINCE(1) FUNC_API_ASYNC FUNC_API_REMOTE_ONLY
+ FUNC_API_SINCE(1) FUNC_API_FAST FUNC_API_REMOTE_ONLY
{
Array rv = ARRAY_DICT_INIT;
@@ -1652,7 +1652,7 @@ typedef kvec_withinit_t(ExprASTConvStackItem, 16) ExprASTConvStack;
/// @param[out] err Error details, if any
Dictionary nvim_parse_expression(String expr, String flags, Boolean highlight,
Error *err)
- FUNC_API_SINCE(4) FUNC_API_ASYNC
+ FUNC_API_SINCE(4) FUNC_API_FAST
{
int pflags = 0;
for (size_t i = 0 ; i < flags.size ; i++) {