patch 9.0.0202: code and help for indexof() is not ideal
Problem: Code and help for indexof() is not ideal.
Solution: Refactor the code, improve the help. (Yegappan Lakshmanan,
closes #10908)
diff --git a/src/testdir/test_vim9_builtin.vim b/src/testdir/test_vim9_builtin.vim
index 212e9f1..244021c 100644
--- a/src/testdir/test_vim9_builtin.vim
+++ b/src/testdir/test_vim9_builtin.vim
@@ -2067,10 +2067,17 @@
enddef
def Test_indexof()
- var l = [{color: 'red'}, {color: 'blue'}, {color: 'green'}]
- indexof(l, (i, v) => v.color == 'green')->assert_equal(2)
+ var l = [{color: 'red'}, {color: 'blue'}, {color: 'green'}, {color: 'blue'}]
+ indexof(l, (i, v) => v.color == 'blue')->assert_equal(1)
+ indexof(l, (i, v) => v.color == 'blue', {startidx: 1})->assert_equal(1)
+ indexof(l, (i, v) => v.color == 'blue', {startidx: 2})->assert_equal(3)
var b = 0zdeadbeef
indexof(b, "v:val == 0xef")->assert_equal(3)
+
+ def TestIdx(k: number, v: dict<any>): bool
+ return v.color == 'blue'
+ enddef
+ indexof(l, TestIdx)->assert_equal(1)
enddef
def Test_input()