vim-patch:9.1.0694: matchparen is slow on a long line (#30134)

Problem:  The matchparen plugin is slow on a long line.
Solution: Don't use a regexp to get char at and before cursor.
          (zeertzjq)

Example:

```vim
  call setline(1, repeat(' foobar', 100000))
  runtime plugin/matchparen.vim
  normal! $hhhhhhhh
```

closes: vim/vim#15568

81e7513c86
This commit is contained in:
zeertzjq
2024-08-25 06:07:43 +08:00
committed by GitHub
parent 84f1c5e072
commit cf44121f7f
3 changed files with 107 additions and 10 deletions

View File

@ -60,12 +60,8 @@ func s:Highlight_Matching_Pair()
let before = 0
let text = getline(c_lnum)
let matches = matchlist(text, '\(.\)\=\%'.c_col.'c\(.\=\)')
if empty(matches)
let [c_before, c] = ['', '']
else
let [c_before, c] = matches[1:2]
endif
let c_before = text->strpart(0, c_col - 1)->slice(-1)
let c = text->strpart(c_col - 1)->slice(0, 1)
let plist = split(&matchpairs, '.\zs[:,]')
let i = index(plist, c)
if i < 0