diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2019-04-13 19:53:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-13 19:53:09 +0200 |
commit | 82d48c0dab0fe595edd6331e0b6ba9630f86b34a (patch) | |
tree | 51a80521ae9bfe4f98c47934133967e456b12aef /src | |
parent | cfe7f896b8e7a9188f79a4633f21e9ac4af57702 (diff) | |
parent | 7e1591e06ab85bf088c7482a15ad48fc58c1005d (diff) | |
download | rneovim-82d48c0dab0fe595edd6331e0b6ba9630f86b34a.tar.gz rneovim-82d48c0dab0fe595edd6331e0b6ba9630f86b34a.tar.bz2 rneovim-82d48c0dab0fe595edd6331e0b6ba9630f86b34a.zip |
Merge pull request #9896 from justinmk/api-async-error
API: emit nvim_error_event on failed async request
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/func_attr.h | 5 | ||||
-rw-r--r-- | src/nvim/msgpack_rpc/channel.c | 16 |
2 files changed, 13 insertions, 8 deletions
diff --git a/src/nvim/func_attr.h b/src/nvim/func_attr.h index 6e5e47c060..d3b600a40c 100644 --- a/src/nvim/func_attr.h +++ b/src/nvim/func_attr.h @@ -205,10 +205,15 @@ #endif #ifdef DEFINE_FUNC_ATTRIBUTES +/// Non-deferred API function. # define FUNC_API_ASYNC +/// Internal C function not exposed in the RPC API. # define FUNC_API_NOEXPORT +/// API function not exposed in VimL/eval. # define FUNC_API_REMOTE_ONLY +/// API function introduced at the given API level. # define FUNC_API_SINCE(X) +/// API function deprecated since the given API level. # define FUNC_API_DEPRECATED_SINCE(X) # define FUNC_ATTR_MALLOC REAL_FATTR_MALLOC # define FUNC_ATTR_ALLOC_SIZE(x) REAL_FATTR_ALLOC_SIZE(x) diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index 4cde9d22a1..3438949e2d 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -348,28 +348,28 @@ static void handle_request(Channel *channel, msgpack_object *request) if (is_get_mode && !input_blocking()) { // Defer the event to a special queue used by os/input.c. #6247 - multiqueue_put(ch_before_blocking_events, response_event, 1, evdata); + multiqueue_put(ch_before_blocking_events, request_event, 1, evdata); } else { // Invoke immediately. - response_event((void **)&evdata); + request_event((void **)&evdata); } } else { - multiqueue_put(channel->events, response_event, 1, evdata); + multiqueue_put(channel->events, request_event, 1, evdata); DLOG("RPC: scheduled %.*s", method->via.bin.size, method->via.bin.ptr); } } -/// Responds to a message, depending on the type: -/// - Request: writes the response. -/// - Notification: does nothing. -static void response_event(void **argv) +/// Handles a message, depending on the type: +/// - Request: invokes method and writes the response (or error). +/// - Notification: invokes method (emits `nvim_error_event` on error). +static void request_event(void **argv) { RequestEvent *e = argv[0]; Channel *channel = e->channel; MsgpackRpcRequestHandler handler = e->handler; Error error = ERROR_INIT; Object result = handler.fn(channel->id, e->args, &error); - if (e->type == kMessageTypeRequest) { + if (e->type == kMessageTypeRequest || ERROR_SET(&error)) { // Send the response. msgpack_packer response; msgpack_packer_init(&response, &out_buffer, msgpack_sbuffer_write); |