aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2018-05-11 10:08:09 +0200
committerJustin M. Keyes <justinkz@gmail.com>2018-05-11 10:08:09 +0200
commit273d2cd5d5cfc7616c76d3531e9938750abcc05e (patch)
tree0783f4e14c18bd0af586f83842e8a238eb1c1e1a /src/nvim/api
parent8d40b3617c8bb10af5d4d4abcab0dfe77a4e807d (diff)
parente31d8ed36a78706cdaa6307cb37ea6a102c5e2f7 (diff)
downloadrneovim-273d2cd5d5cfc7616c76d3531e9938750abcc05e.tar.gz
rneovim-273d2cd5d5cfc7616c76d3531e9938750abcc05e.tar.bz2
rneovim-273d2cd5d5cfc7616c76d3531e9938750abcc05e.zip
Merge #8329 'API: Make nvim_set_option() update `:verbose set …`'
Diffstat (limited to 'src/nvim/api')
-rw-r--r--src/nvim/api/buffer.c5
-rw-r--r--src/nvim/api/private/helpers.c25
-rw-r--r--src/nvim/api/vim.c4
-rw-r--r--src/nvim/api/window.c5
4 files changed, 25 insertions, 14 deletions
diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c
index 6be981a18e..023f434f9d 100644
--- a/src/nvim/api/buffer.c
+++ b/src/nvim/api/buffer.c
@@ -581,7 +581,8 @@ Object nvim_buf_get_option(Buffer buffer, String name, Error *err)
/// @param name Option name
/// @param value Option value
/// @param[out] err Error details, if any
-void nvim_buf_set_option(Buffer buffer, String name, Object value, Error *err)
+void nvim_buf_set_option(uint64_t channel_id, Buffer buffer,
+ String name, Object value, Error *err)
FUNC_API_SINCE(1)
{
buf_T *buf = find_buffer_by_handle(buffer, err);
@@ -590,7 +591,7 @@ void nvim_buf_set_option(Buffer buffer, String name, Object value, Error *err)
return;
}
- set_option_to(buf, SREQ_BUF, name, value, err);
+ set_option_to(channel_id, buf, SREQ_BUF, name, value, err);
}
/// Gets the buffer number
diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c
index 637e24575d..b922036893 100644
--- a/src/nvim/api/private/helpers.c
+++ b/src/nvim/api/private/helpers.c
@@ -324,7 +324,8 @@ Object get_option_from(void *from, int type, String name, Error *err)
/// @param type One of `SREQ_GLOBAL`, `SREQ_WIN` or `SREQ_BUF`
/// @param name The option name
/// @param[out] err Details of an error that may have occurred
-void set_option_to(void *to, int type, String name, Object value, Error *err)
+void set_option_to(uint64_t channel_id, void *to, int type,
+ String name, Object value, Error *err)
{
if (name.size == 0) {
api_set_error(err, kErrorTypeValidation, "Empty option name");
@@ -361,7 +362,8 @@ void set_option_to(void *to, int type, String name, Object value, Error *err)
}
}
- int opt_flags = (type == SREQ_GLOBAL) ? OPT_GLOBAL : OPT_LOCAL;
+ int numval = 0;
+ char *stringval = NULL;
if (flags & SOPT_BOOL) {
if (value.type != kObjectTypeBoolean) {
@@ -372,8 +374,7 @@ void set_option_to(void *to, int type, String name, Object value, Error *err)
return;
}
- bool val = value.data.boolean;
- set_option_value_for(name.data, val, NULL, opt_flags, type, to, err);
+ numval = value.data.boolean;
} else if (flags & SOPT_NUM) {
if (value.type != kObjectTypeInteger) {
api_set_error(err,
@@ -391,8 +392,7 @@ void set_option_to(void *to, int type, String name, Object value, Error *err)
return;
}
- int val = (int) value.data.integer;
- set_option_value_for(name.data, val, NULL, opt_flags, type, to, err);
+ numval = (int)value.data.integer;
} else {
if (value.type != kObjectTypeString) {
api_set_error(err,
@@ -402,9 +402,18 @@ void set_option_to(void *to, int type, String name, Object value, Error *err)
return;
}
- set_option_value_for(name.data, 0, value.data.string.data,
- opt_flags, type, to, err);
+ stringval = (char *)value.data.string.data;
}
+
+ const scid_T save_current_SID = current_SID;
+ current_SID = channel_id == LUA_INTERNAL_CALL ? SID_LUA : SID_API_CLIENT;
+ current_channel_id = channel_id;
+
+ const int opt_flags = (type == SREQ_GLOBAL) ? OPT_GLOBAL : OPT_LOCAL;
+ set_option_value_for(name.data, numval, stringval,
+ opt_flags, type, to, err);
+
+ current_SID = save_current_SID;
}
#define TYPVAL_ENCODE_ALLOW_SPECIALS false
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index fd9cf332d5..df4912a51e 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -683,10 +683,10 @@ Object nvim_get_option(String name, Error *err)
/// @param name Option name
/// @param value New option value
/// @param[out] err Error details, if any
-void nvim_set_option(String name, Object value, Error *err)
+void nvim_set_option(uint64_t channel_id, String name, Object value, Error *err)
FUNC_API_SINCE(1)
{
- set_option_to(NULL, SREQ_GLOBAL, name, value, err);
+ set_option_to(channel_id, NULL, SREQ_GLOBAL, name, value, err);
}
/// Writes a message to the Vim output buffer. Does not append "\n", the
diff --git a/src/nvim/api/window.c b/src/nvim/api/window.c
index 9bc91ef8fb..abfa0dc20b 100644
--- a/src/nvim/api/window.c
+++ b/src/nvim/api/window.c
@@ -309,7 +309,8 @@ Object nvim_win_get_option(Window window, String name, Error *err)
/// @param name Option name
/// @param value Option value
/// @param[out] err Error details, if any
-void nvim_win_set_option(Window window, String name, Object value, Error *err)
+void nvim_win_set_option(uint64_t channel_id, Window window,
+ String name, Object value, Error *err)
FUNC_API_SINCE(1)
{
win_T *win = find_window_by_handle(window, err);
@@ -318,7 +319,7 @@ void nvim_win_set_option(Window window, String name, Object value, Error *err)
return;
}
- set_option_to(win, SREQ_WIN, name, value, err);
+ set_option_to(channel_id, win, SREQ_WIN, name, value, err);
}
/// Gets the window position in display cells. First position is zero.