Skip to content

Commit

Permalink
feat(api): update nvim_exec2() to use api_object_to_bool()
Browse files Browse the repository at this point in the history
  • Loading branch information
echasnovski committed Mar 24, 2023
1 parent 9568f07 commit 95bffff
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/nvim/api/vimscript.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ Dictionary nvim_exec2(uint64_t channel_id, String src, Dict(exec_opts) *opts, Er
if (ERROR_SET(err)) {
return result;
}
if (HAS_KEY(opts->output) && opts->output.data.boolean) {

if (HAS_KEY(opts->output) && api_object_to_bool(opts->output, "opts.output", false, err)) {
PUT(result, "output", STRING_OBJ(output));
}

Expand All @@ -69,15 +70,7 @@ Dictionary nvim_exec2(uint64_t channel_id, String src, Dict(exec_opts) *opts, Er

String exec_impl(uint64_t channel_id, String src, Dict(exec_opts) *opts, Error *err)
{
Boolean output = false;
if (HAS_KEY(opts->output)) {
if (opts->output.type != kObjectTypeBoolean) {
api_set_error(err, kErrorTypeValidation, "'output' should be boolean");
return (String)STRING_INIT;
}

output = opts->output.data.boolean;
}
Boolean output = api_object_to_bool(opts->output, "opts.output", false, err);

const int save_msg_silent = msg_silent;
garray_T *const save_capture_ga = capture_ga;
Expand Down

0 comments on commit 95bffff

Please sign in to comment.