summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvimboss <devnull@localhost>2009-11-17 11:20:35 +0000
committervimboss <devnull@localhost>2009-11-17 11:20:35 +0000
commite8fb6ea0822655af449ca6743ba9065241761c47 (patch)
treefdc9496bb9adc2d4519a80b21368a0ee0e6dadf1
parente775a97ddbd11c79aeca0afbe6b99ce2732633b8 (diff)
downloadvim-e8fb6ea0822655af449ca6743ba9065241761c47.tar.gz
updated for version 7.2-295v7.2.295v7-2-295
-rw-r--r--runtime/doc/eval.txt3
-rw-r--r--src/eval.c10
-rw-r--r--src/version.c2
3 files changed, 11 insertions, 4 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index ba498af2..afa38a49 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -3802,7 +3802,8 @@ map({expr}, {string}) *map()*
Replace each item in {expr} with the result of evaluating
{string}.
Inside {string} |v:val| has the value of the current item.
- For a |Dictionary| |v:key| has the key of the current item.
+ For a |Dictionary| |v:key| has the key of the current item
+ and for a |List| |v:key| has the index of the current item.
Example: >
:call map(mylist, '"> " . v:val . " <"')
< This puts "> " before and " <" after each item in "mylist".
diff --git a/src/eval.c b/src/eval.c
index 40fcfefb..9f704677 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -9928,6 +9928,7 @@ filter_map(argvars, rettv, map)
int todo;
char_u *ermsg = map ? (char_u *)"map()" : (char_u *)"filter()";
int save_did_emsg;
+ int index = 0;
if (argvars[0].v_type == VAR_LIST)
{
@@ -9961,9 +9962,9 @@ filter_map(argvars, rettv, map)
save_did_emsg = did_emsg;
did_emsg = FALSE;
+ prepare_vimvar(VV_KEY, &save_key);
if (argvars[0].v_type == VAR_DICT)
{
- prepare_vimvar(VV_KEY, &save_key);
vimvars[VV_KEY].vv_type = VAR_STRING;
ht = &d->dv_hashtab;
@@ -9987,24 +9988,27 @@ filter_map(argvars, rettv, map)
}
}
hash_unlock(ht);
-
- restore_vimvar(VV_KEY, &save_key);
}
else
{
+ vimvars[VV_KEY].vv_type = VAR_NUMBER;
+
for (li = l->lv_first; li != NULL; li = nli)
{
if (tv_check_lock(li->li_tv.v_lock, ermsg))
break;
nli = li->li_next;
+ vimvars[VV_KEY].vv_nr = index;
if (filter_map_one(&li->li_tv, expr, map, &rem) == FAIL
|| did_emsg)
break;
if (!map && rem)
listitem_remove(l, li);
+ ++index;
}
}
+ restore_vimvar(VV_KEY, &save_key);
restore_vimvar(VV_VAL, &save_val);
did_emsg |= save_did_emsg;
diff --git a/src/version.c b/src/version.c
index e98bda8a..19ac2a8f 100644
--- a/src/version.c
+++ b/src/version.c
@@ -682,6 +682,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 295,
+/**/
294,
/**/
293,