aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorScott Prager <splinterofchaos@gmail.com>2014-10-09 22:09:52 -0400
committerScott Prager <splinterofchaos@gmail.com>2014-10-09 22:09:52 -0400
commit21d1016f56bd15a480e312f95ac19effdb1138e4 (patch)
tree977d70ff0c83cf839b04d3fd3c24dd5a87735329 /runtime
parent7e229e78e9e9976783fab14d21f2605169f93193 (diff)
downloadrneovim-21d1016f56bd15a480e312f95ac19effdb1138e4.tar.gz
rneovim-21d1016f56bd15a480e312f95ac19effdb1138e4.tar.bz2
rneovim-21d1016f56bd15a480e312f95ac19effdb1138e4.zip
vim-patch:7.4.397
Problem: Matchparen only uses the topmost syntax item. Solution: Go through the syntax stack to find items. (James McCoy) Also use getcurpos() when possible. https://code.google.com/p/vim/source/detail?r=v7-4-397
Diffstat (limited to 'runtime')
-rw-r--r--runtime/plugin/matchparen.vim13
1 files changed, 10 insertions, 3 deletions
diff --git a/runtime/plugin/matchparen.vim b/runtime/plugin/matchparen.vim
index 817ce62b28..3804ab949a 100644
--- a/runtime/plugin/matchparen.vim
+++ b/runtime/plugin/matchparen.vim
@@ -98,10 +98,17 @@ function! s:Highlight_Matching_Pair()
call cursor(c_lnum, c_col - before)
endif
- " When not in a string or comment ignore matches inside them.
+ " Build an expression that detects whether the current cursor position is in
+ " certain syntax types (string, comment, etc.), for use as searchpairpos()'s
+ " skip argument.
" We match "escape" for special items, such as lispEscapeSpecial.
- let s_skip ='synIDattr(synID(line("."), col("."), 0), "name") ' .
- \ '=~? "string\\|character\\|singlequote\\|escape\\|comment"'
+ let s_skip = '!empty(filter(map(synstack(line("."), col(".")), ''synIDattr(v:val, "name")''), ' .
+ \ '''v:val =~? "string\\|character\\|singlequote\\|escape\\|comment"''))'
+ " If executing the expression determines that the cursor is currently in
+ " one of the syntax types, then we want searchpairpos() to find the pair
+ " within those syntax types (i.e., not skip). Otherwise, the cursor is
+ " outside of the syntax types and s_skip should keep its value so we skip any
+ " matching pair inside the syntax types.
execute 'if' s_skip '| let s_skip = 0 | endif'
" Limit the search to lines visible in the window.