[vim/vim] Escaped `,` and `:` in patterns in `b:match_words` is not correctly unescaped (Issue #14814)

3 views
Skip to first unread message

Linda_pp

unread,
May 20, 2024, 1:00:46 PMMay 20
to vim/vim, Subscribed

Steps to reproduce

Prepare the following file as test.vimrc:

set nocompatible
packadd! matchit
autocmd BufReadPost * let b:match_words = '^A\{5\,}:^B\{5\,}'

And prepare the following file as test.txt:

AAAAAA

BBBBBB

Then open Vim

vim -u test.vimrc test.txt

Finally type % on the first A in the first line.

This causes the following errors:

Error detected while processing function matchit#Match_wrapper[85]..<SNR>15_Wholematch:
line    5:
E554: Syntax error in \{...}
E870: (NFA regexp) Error reading repetition limits
Error detected while processing function matchit#Match_wrapper:
line   86:
E554: Syntax error in \{...}
E870: (NFA regexp) Error reading repetition limits
Press ENTER or type command to continue

Expected behaviour

Since '^A\{5\,}:^B\{5\,}' is set to b:match_words, matchit.vim should jump between AAAAAA and BBBBBB without any error.

In this example output, comma is escaped as \, not to conflict with delimiter of patterns. This is explained in doc/matchit.vim as follows:

The format for |b:match_words| is similar to that of the 'matchpairs' option:
it is a comma (,)-separated list of groups; each group is a colon(:)-separated
list of patterns (regular expressions). Commas and colons that are part of a
pattern should be escaped with backslashes (':' and ',').

Version of Vim

Master branch (5f1b115)

Environment

  • Operating system: macOS 13
  • Terminal: iTerm2
  • $TERM: screen-256color
  • Shell: zsh 5.9

Logs and stack traces

I investigated this issue by doing some print debugging and found that the escaped `\,` characters are not un-escaped actually. The backslash remained in the patterns so the regex engine complained that `A\{7\,}` was an invalid expression.


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/14814@github.com>

Christian Brabandt

unread,
May 20, 2024, 1:56:46 PMMay 20
to vim/vim, Subscribed

Closed #14814 as completed via chrisbra/matchit@d167669.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issue/14814/issue_event/12869299051@github.com>

Reply all
Reply to author
Forward
0 new messages