diff options
author | ZyX <kp-pav@yandex.ru> | 2016-02-11 02:01:17 +0300 |
---|---|---|
committer | ZyX <kp-pav@yandex.ru> | 2016-04-18 02:47:13 +0300 |
commit | f1ced96c28b7db7b3dad9b0ca2f71f8d046ef732 (patch) | |
tree | 650bafc7e2d19fe535a93973fe5bf176b03a33f0 /src/nvim/api/window.c | |
parent | af6603a6b4c9b1cb4a65eb2dc581295d8990c5ef (diff) | |
download | rneovim-f1ced96c28b7db7b3dad9b0ca2f71f8d046ef732.tar.gz rneovim-f1ced96c28b7db7b3dad9b0ca2f71f8d046ef732.tar.bz2 rneovim-f1ced96c28b7db7b3dad9b0ca2f71f8d046ef732.zip |
api: Replace set_var(name, NIL) with del_var(name)
Diffstat (limited to 'src/nvim/api/window.c')
-rw-r--r-- | src/nvim/api/window.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/nvim/api/window.c b/src/nvim/api/window.c index aad616c7bf..58218af09d 100644 --- a/src/nvim/api/window.c +++ b/src/nvim/api/window.c @@ -197,7 +197,7 @@ Object window_get_var(Window window, String name, Error *err) return dict_get_value(win->w_vars, name, err); } -/// Sets a window-scoped (w:) variable. 'nil' value deletes the variable. +/// Sets a window-scoped (w:) variable /// /// @param window The window handle /// @param name The variable name @@ -212,7 +212,24 @@ Object window_set_var(Window window, String name, Object value, Error *err) return (Object) OBJECT_INIT; } - return dict_set_value(win->w_vars, name, value, err); + return dict_set_value(win->w_vars, name, value, false, err); +} + +/// Removes a window-scoped (w:) variable +/// +/// @param window The window handle +/// @param name The variable name +/// @param[out] err Details of an error that may have occurred +/// @return The old value +Object window_del_var(Window window, String name, Error *err) +{ + win_T *win = find_window_by_handle(window, err); + + if (!win) { + return (Object) OBJECT_INIT; + } + + return dict_set_value(win->w_vars, name, NIL, true, err); } /// Gets a window option value |