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>
diff --git a/runtime/plugin/matchparen.vim b/runtime/plugin/matchparen.vim
index 6c061c9..2899612 100644
--- a/runtime/plugin/matchparen.vim
+++ b/runtime/plugin/matchparen.vim
@@ -60,12 +60,8 @@
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