Skip to content

Instantly share code, notes, and snippets.

@h-east
Created December 8, 2018 11:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save h-east/f229f9c380bd86c574f5ef421633e87b to your computer and use it in GitHub Desktop.
Save h-east/f229f9c380bd86c574f5ef421633e87b to your computer and use it in GitHub Desktop.
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 22a4c0054..abb9ccfbd 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -4043,10 +4043,10 @@ flatten({list} [, {maxdepth}]) *flatten()*
:echo flatten([1, [2], 3])
< [1, 2, 3] >
:echo flatten([[[1], [2], [3]]], 1)
-
-< [[1], [2], [3]]
+< [[1], [2], [3]]
*E964*
{maxdepth} must be positive number.
+
float2nr({expr}) *float2nr()*
Convert {expr} to a Number by omitting the part after the
decimal point.
diff --git a/runtime/doc/usr_41.txt b/runtime/doc/usr_41.txt
index c7e595586..6b51e7ba3 100644
--- a/runtime/doc/usr_41.txt
+++ b/runtime/doc/usr_41.txt
@@ -639,6 +639,7 @@ List manipulation: *list-functions*
min() minimum value in a List
count() count number of times a value appears in a List
repeat() repeat a List multiple times
+ flatten() Flatten a List
Dictionary manipulation: *dict-functions*
get() get an entry without an error for a wrong key
diff --git a/src/evalfunc.c b/src/evalfunc.c
index c8c5a41a5..7537891c2 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -3858,9 +3858,7 @@ f_flatten(typval_T *argvars, typval_T *rettv)
}
if (argvars[1].v_type == VAR_UNKNOWN)
- {
maxdepth = 1;
- }
else
{
maxdepth = (long)get_tv_number_chk(&argvars[1], &error);
@@ -3873,8 +3871,8 @@ f_flatten(typval_T *argvars, typval_T *rettv)
}
}
- if ((l = argvars[0].vval.v_list) != NULL
- && !tv_check_lock(l->lv_lock, (char_u *)N_("flatten() argument"), TRUE)
+ if ((l = argvars[0].vval.v_list) != NULL && !tv_check_lock(l->lv_lock,
+ (char_u *)N_("flatten() argument"), TRUE)
&& list_flatten(l, maxdepth) == OK)
copy_tv(&argvars[0], rettv);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment