Mercurial > vim
diff src/testdir/test_search.vim @ 29224:ca46658481cf v8.2.5131
patch 8.2.5131: timeout implementation is not optimal
Commit: https://github.com/vim/vim/commit/e530395c2cd261d598094dc9ea785e90a753c5f1
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jun 19 17:05:47 2022 +0100
patch 8.2.5131: timeout implementation is not optimal
Problem: Timeout implementation is not optimal.
Solution: Further improvements for timeouts. Add a test for searchpair()
timeout. (partly by Paul Ollis)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 19 Jun 2022 18:15:03 +0200 |
parents | 0af5fe160e4e |
children | 96ff6c230a66 |
line wrap: on
line diff
--- a/src/testdir/test_search.vim +++ b/src/testdir/test_search.vim @@ -355,6 +355,37 @@ func Test_searchpair_timeout() bwipe! endfunc +func SearchpairSkip() + let id = synID(line('.'), col('.'), 0) + let attr = synIDattr(id, 'name') + return attr !~ 'comment' +endfunc + +func Test_searchpair_timeout_with_skip() + let g:test_is_flaky = 1 + + edit ../evalfunc.c + if has('win32') + " Windows timeouts are rather coarse grained, about 16ms. + let ms = 20 + let min_time = 0.016 + let max_time = min_time * 10.0 + else + let ms = 1 + let min_time = 0.001 + let max_time = min_time * 10.0 + if GetVimCommand() =~ 'valgrind.*--log-file=' + let max_time += 0.04 " this can be slow with valgrind + endif + endif + let start = reltime() + let found = searchpair('(', '', ')', 'crnm', 'SearchpairSkip()', 0, ms) + let elapsed = reltimefloat(reltime(start)) + call assert_inrange(min_time, max_time, elapsed) + + bwipe! +endfunc + func Test_searchpairpos() new call setline(1, ['other code', 'here [', ' [', ' " cursor here', ' ]]'])