patch 9.1.0694: matchparen is slow on a long line

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: #15568

Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
zeertzjq
2024-08-24 16:32:24 +02:00
committed by Christian Brabandt
parent dc2c75c6b5
commit 81e7513c86
11 changed files with 114 additions and 6 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