summaryrefslogtreecommitdiffstats
path: root/src/dict.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-08-18 13:04:15 +0200
committerBram Moolenaar <Bram@vim.org>2020-08-18 13:04:15 +0200
commit558813314d63dd0263a7a86c0496c1e89b5c8cba (patch)
tree7ebfbe1f61edc2bfb5fc82f354bf6f7cae5391ec /src/dict.c
parentf39397e515067d5a314be99778e63fe0acf93c51 (diff)
patch 8.2.1478: Vim9: cannot use "true" for some popup optionsv8.2.1478
Problem: Vim9: cannot use "true" for some popup options. Solution: Add dict_get_bool(). (closes #6725)
Diffstat (limited to 'src/dict.c')
-rw-r--r--src/dict.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/dict.c b/src/dict.c
index b3517309ae..01a2edaa28 100644
--- a/src/dict.c
+++ b/src/dict.c
@@ -703,6 +703,21 @@ dict_get_number_check(dict_T *d, char_u *key)
}
/*
+ * Get a bool item (number or true/false) from a dictionary.
+ * Returns "def" if the entry doesn't exist.
+ */
+ varnumber_T
+dict_get_bool(dict_T *d, char_u *key, int def)
+{
+ dictitem_T *di;
+
+ di = dict_find(d, key, -1);
+ if (di == NULL)
+ return def;
+ return tv_get_bool(&di->di_tv);
+}
+
+/*
* Return an allocated string with the string representation of a Dictionary.
* May return NULL.
*/