| To: vim_dev@googlegroups.com |
| Subject: Patch 7.4.397 |
| Fcc: outbox |
| From: Bram Moolenaar <Bram@moolenaar.net> |
| Mime-Version: 1.0 |
| Content-Type: text/plain; charset=UTF-8 |
| Content-Transfer-Encoding: 8bit |
| |
| |
| 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. |
| Files: runtime/plugin/matchparen.vim |
| |
| |
| |
| |
| |
| *** 1,6 **** |
| " Vim plugin for showing matching parens |
| " Maintainer: Bram Moolenaar <Bram@vim.org> |
| ! " Last Change: 2014 Jun 17 |
| |
| " Exit quickly when: |
| " - this plugin was already loaded (or disabled) |
| --- 1,6 ---- |
| " Vim plugin for showing matching parens |
| " Maintainer: Bram Moolenaar <Bram@vim.org> |
| ! " Last Change: 2014 Jul 19 |
| |
| " Exit quickly when: |
| " - this plugin was already loaded (or disabled) |
| |
| *** 54,67 **** |
| let c_col = col('.') |
| let before = 0 |
| |
| ! let c = getline(c_lnum)[c_col - 1] |
| let plist = split(&matchpairs, '.\zs[:,]') |
| let i = index(plist, c) |
| if i < 0 |
| " not found, in Insert mode try character before the cursor |
| if c_col > 1 && (mode() == 'i' || mode() == 'R') |
| let before = 1 |
| ! let c = getline(c_lnum)[c_col - 2] |
| let i = index(plist, c) |
| endif |
| if i < 0 |
| --- 54,68 ---- |
| let c_col = col('.') |
| let before = 0 |
| |
| ! let text = getline(c_lnum) |
| ! let c = text[c_col - 1] |
| let plist = split(&matchpairs, '.\zs[:,]') |
| let i = index(plist, c) |
| if i < 0 |
| " not found, in Insert mode try character before the cursor |
| if c_col > 1 && (mode() == 'i' || mode() == 'R') |
| let before = 1 |
| ! let c = text[c_col - 2] |
| let i = index(plist, c) |
| endif |
| if i < 0 |
| |
| *** 87,100 **** |
| " Find the match. When it was just before the cursor move it there for a |
| " moment. |
| if before > 0 |
| ! let save_cursor = winsaveview() |
| call cursor(c_lnum, c_col - before) |
| endif |
| |
| ! " When not in a string or comment ignore matches inside them. |
| " We match "escape" for special items, such as lispEscapeSpecial. |
| ! let s_skip ='synIDattr(synID(line("."), col("."), 0), "name") ' . |
| ! \ '=~? "string\\|character\\|singlequote\\|escape\\|comment"' |
| execute 'if' s_skip '| let s_skip = 0 | endif' |
| |
| " Limit the search to lines visible in the window. |
| --- 88,114 ---- |
| " Find the match. When it was just before the cursor move it there for a |
| " moment. |
| if before > 0 |
| ! let has_getcurpos = exists("*getcurpos") |
| ! if has_getcurpos |
| ! " getcurpos() is more efficient but doesn't exist before 7.4.313. |
| ! let save_cursor = getcurpos() |
| ! else |
| ! let save_cursor = winsaveview() |
| ! endif |
| call cursor(c_lnum, c_col - before) |
| endif |
| |
| ! " 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 = '!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. |
| |
| *** 147,153 **** |
| endtry |
| |
| if before > 0 |
| ! call winrestview(save_cursor) |
| endif |
| |
| " If a match is found setup match highlighting. |
| --- 161,171 ---- |
| endtry |
| |
| if before > 0 |
| ! if has_getcurpos |
| ! call setpos('.', save_cursor) |
| ! else |
| ! call winrestview(save_cursor) |
| ! endif |
| endif |
| |
| " If a match is found setup match highlighting. |
| |
| |
| |
| *** 743,744 **** |
| --- 743,746 ---- |
| { /* Add new patch number below this line */ |
| + /**/ |
| + 397, |
| /**/ |
| |
| -- |
| Often you're less important than your furniture. If you think about it, you |
| can get fired but your furniture stays behind, gainfully employed at the |
| company that didn't need _you_ anymore. |
| (Scott Adams - The Dilbert principle) |
| |
| /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ |
| /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ |
| \\\ an exciting new programming language -- http://www.Zimbu.org /// |
| \\\ help me help AIDS victims -- http://ICCF-Holland.org /// |