Hi Benji and list,
I found a problem that % in Operator pending mode doesn't work properly
when multibyte characters are set in b:match_words.
E.g. consider setting "(" (U+FF08, FULLWIDTH LEFT PARENTHESIS) and
")" (U+FF09, FULLWIDTH RIGHT PARENTHESIS) as a pair.
Step to reproduce:
1. Execute vim with the following command line
vim -u NONE -N -c 'runtime macros/matchit.vim' -c 'let b:match_words="(:)"'
2. Insert the following text
aaa(bbb)ccc
3. Move the cursor on (, then type d%
Actual result is:
aaac
Expected result is:
aaaccc
This is caused in s:CleanUp(). Character count should be used instead of
byte count.
The following patch fixes the problem:
--- a/runtime/macros/matchit.vim
+++ b/runtime/macros/matchit.vim
@@ -303,7 +303,10 @@ fun! s:CleanUp(options, mode, startline,
let regexp = s:Wholematch(matchline, a:1, currcol-1)
let endcol = matchend(matchline, regexp)
if endcol > currcol " This is NOT off by one!
- execute "normal!" . (endcol - currcol) . "l"
+ let charcount = strlen(substitute(matchline[currcol-1 : endcol-1], ".",
"x", "g"))
+ if charcount > 1
+ execute "normal!" . (charcount - 1) . "l"
+ endif
endif
endif " a:0
endif " a:mode != "o" && etc.
Note: This patch can be a little bit simple after Vim 7.4.755.
Before 7.4.755:
let charcount = strlen(substitute(matchline[currcol-1 : endcol-1], ".", "x",
"g"))
After 7.4.755:
let charcount = strchars(matchline[currcol-1 : endcol-1], 1)
More detail:
https://github.com/vim-jp/vim/blob/v7-4-778/runtime/doc/eval.txt#L5855-5873
Regards,
Ken Takata
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.