summaryrefslogtreecommitdiff
path: root/src/testdir/test_match.vim
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-09-29 13:50:08 +0100
committerBram Moolenaar <Bram@vim.org>2022-09-29 13:50:08 +0100
commit9f573a8df02d9f699a43d2afbd1d2841d700b9ad (patch)
tree8b68307515d0dce34622ef379b11c166a6f2f7d3 /src/testdir/test_match.vim
parentfc06cda8379031890ee8852cdca61eb8af8e1ba2 (diff)
downloadvim-git-9f573a8df02d9f699a43d2afbd1d2841d700b9ad.tar.gz
patch 9.0.0622: matchaddpos() can get slow when adding many matchesv9.0.0622
Problem: matchaddpos() can get slow when adding many matches. Solution: Update the next available match ID when manually picking an ID and remove check if the available ID can be used. (idea by Rick Howe)
Diffstat (limited to 'src/testdir/test_match.vim')
-rw-r--r--src/testdir/test_match.vim14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/testdir/test_match.vim b/src/testdir/test_match.vim
index 91e78a768..8be5bc080 100644
--- a/src/testdir/test_match.vim
+++ b/src/testdir/test_match.vim
@@ -36,8 +36,8 @@ function Test_match()
let m1 = matchadd("MyGroup1", "TODO")
let m2 = matchadd("MyGroup2", "FIXME", 42)
let m3 = matchadd("MyGroup3", "XXX", 60, 17)
- let ans = [{'group': 'MyGroup1', 'pattern': 'TODO', 'priority': 10, 'id': 4},
- \ {'group': 'MyGroup2', 'pattern': 'FIXME', 'priority': 42, 'id': 5},
+ let ans = [{'group': 'MyGroup1', 'pattern': 'TODO', 'priority': 10, 'id': 1000},
+ \ {'group': 'MyGroup2', 'pattern': 'FIXME', 'priority': 42, 'id': 1001},
\ {'group': 'MyGroup3', 'pattern': 'XXX', 'priority': 60, 'id': 17}]
call assert_equal(ans, getmatches())
@@ -119,7 +119,7 @@ function Test_match()
call clearmatches()
call setline(1, 'abcdΣabcdef')
- eval "MyGroup1"->matchaddpos([[1, 4, 2], [1, 9, 2]])
+ eval "MyGroup1"->matchaddpos([[1, 4, 2], [1, 9, 2]], 10, 42)
1
redraw!
let v1 = screenattr(1, 1)
@@ -130,7 +130,7 @@ function Test_match()
let v8 = screenattr(1, 8)
let v9 = screenattr(1, 9)
let v10 = screenattr(1, 10)
- call assert_equal([{'group': 'MyGroup1', 'id': 11, 'priority': 10, 'pos1': [1, 4, 2], 'pos2': [1, 9, 2]}], getmatches())
+ call assert_equal([{'group': 'MyGroup1', 'id': 42, 'priority': 10, 'pos1': [1, 4, 2], 'pos2': [1, 9, 2]}], getmatches())
call assert_notequal(v1, v4)
call assert_equal(v5, v4)
call assert_equal(v6, v1)
@@ -144,7 +144,7 @@ function Test_match()
let m=getmatches()
call clearmatches()
call setmatches(m)
- call assert_equal([{'group': 'MyGroup1', 'id': 11, 'priority': 10, 'pos1': [1, 4, 2], 'pos2': [1,9, 2]}, {'group': 'MyGroup1', 'pattern': '\%2lmatchadd', 'priority': 10, 'id': 12}], getmatches())
+ call assert_equal([{'group': 'MyGroup1', 'id': 42, 'priority': 10, 'pos1': [1, 4, 2], 'pos2': [1,9, 2]}, {'group': 'MyGroup1', 'pattern': '\%2lmatchadd', 'priority': 10, 'id': 1106}], getmatches())
highlight MyGroup1 NONE
highlight MyGroup2 NONE
@@ -252,8 +252,8 @@ func Test_matchaddpos_otherwin()
let savematches = getmatches(winid)
let expect = [
- \ {'group': 'Search', 'pattern': '4', 'priority': 10, 'id': 4},
- \ {'group': 'Error', 'id': 5, 'priority': 10, 'pos1': [1, 2, 1], 'pos2': [2, 2, 1]},
+ \ {'group': 'Search', 'pattern': '4', 'priority': 10, 'id': 1000},
+ \ {'group': 'Error', 'id': 1001, 'priority': 10, 'pos1': [1, 2, 1], 'pos2': [2, 2, 1]},
\]
call assert_equal(expect, savematches)