3ef2ca
To: vim_dev@googlegroups.com
3ef2ca
Subject: Patch 7.4.397
3ef2ca
Fcc: outbox
3ef2ca
From: Bram Moolenaar <Bram@moolenaar.net>
3ef2ca
Mime-Version: 1.0
3ef2ca
Content-Type: text/plain; charset=UTF-8
3ef2ca
Content-Transfer-Encoding: 8bit
3ef2ca
------------
3ef2ca
3ef2ca
Patch 7.4.397
3ef2ca
Problem:    Matchparen only uses the topmost syntax item.
3ef2ca
Solution:   Go through the syntax stack to find items. (James McCoy)
3ef2ca
            Also use getcurpos() when possible.
3ef2ca
Files:      runtime/plugin/matchparen.vim
3ef2ca
3ef2ca
3ef2ca
*** ../vim-7.4.396/runtime/plugin/matchparen.vim	2014-06-17 17:48:21.772628007 +0200
3ef2ca
--- runtime/plugin/matchparen.vim	2014-08-06 19:02:04.967128364 +0200
3ef2ca
***************
3ef2ca
*** 1,6 ****
3ef2ca
  " Vim plugin for showing matching parens
3ef2ca
  " Maintainer:  Bram Moolenaar <Bram@vim.org>
3ef2ca
! " Last Change: 2014 Jun 17
3ef2ca
  
3ef2ca
  " Exit quickly when:
3ef2ca
  " - this plugin was already loaded (or disabled)
3ef2ca
--- 1,6 ----
3ef2ca
  " Vim plugin for showing matching parens
3ef2ca
  " Maintainer:  Bram Moolenaar <Bram@vim.org>
3ef2ca
! " Last Change: 2014 Jul 19
3ef2ca
  
3ef2ca
  " Exit quickly when:
3ef2ca
  " - this plugin was already loaded (or disabled)
3ef2ca
***************
3ef2ca
*** 54,67 ****
3ef2ca
    let c_col = col('.')
3ef2ca
    let before = 0
3ef2ca
  
3ef2ca
!   let c = getline(c_lnum)[c_col - 1]
3ef2ca
    let plist = split(&matchpairs, '.\zs[:,]')
3ef2ca
    let i = index(plist, c)
3ef2ca
    if i < 0
3ef2ca
      " not found, in Insert mode try character before the cursor
3ef2ca
      if c_col > 1 && (mode() == 'i' || mode() == 'R')
3ef2ca
        let before = 1
3ef2ca
!       let c = getline(c_lnum)[c_col - 2]
3ef2ca
        let i = index(plist, c)
3ef2ca
      endif
3ef2ca
      if i < 0
3ef2ca
--- 54,68 ----
3ef2ca
    let c_col = col('.')
3ef2ca
    let before = 0
3ef2ca
  
3ef2ca
!   let text = getline(c_lnum)
3ef2ca
!   let c = text[c_col - 1]
3ef2ca
    let plist = split(&matchpairs, '.\zs[:,]')
3ef2ca
    let i = index(plist, c)
3ef2ca
    if i < 0
3ef2ca
      " not found, in Insert mode try character before the cursor
3ef2ca
      if c_col > 1 && (mode() == 'i' || mode() == 'R')
3ef2ca
        let before = 1
3ef2ca
!       let c = text[c_col - 2]
3ef2ca
        let i = index(plist, c)
3ef2ca
      endif
3ef2ca
      if i < 0
3ef2ca
***************
3ef2ca
*** 87,100 ****
3ef2ca
    " Find the match.  When it was just before the cursor move it there for a
3ef2ca
    " moment.
3ef2ca
    if before > 0
3ef2ca
!     let save_cursor = winsaveview()
3ef2ca
      call cursor(c_lnum, c_col - before)
3ef2ca
    endif
3ef2ca
  
3ef2ca
!   " When not in a string or comment ignore matches inside them.
3ef2ca
    " We match "escape" for special items, such as lispEscapeSpecial.
3ef2ca
!   let s_skip ='synIDattr(synID(line("."), col("."), 0), "name") ' .
3ef2ca
! 	\ '=~?  "string\\|character\\|singlequote\\|escape\\|comment"'
3ef2ca
    execute 'if' s_skip '| let s_skip = 0 | endif'
3ef2ca
  
3ef2ca
    " Limit the search to lines visible in the window.
3ef2ca
--- 88,114 ----
3ef2ca
    " Find the match.  When it was just before the cursor move it there for a
3ef2ca
    " moment.
3ef2ca
    if before > 0
3ef2ca
!     let has_getcurpos = exists("*getcurpos")
3ef2ca
!     if has_getcurpos
3ef2ca
!       " getcurpos() is more efficient but doesn't exist before 7.4.313.
3ef2ca
!       let save_cursor = getcurpos()
3ef2ca
!     else
3ef2ca
!       let save_cursor = winsaveview()
3ef2ca
!     endif
3ef2ca
      call cursor(c_lnum, c_col - before)
3ef2ca
    endif
3ef2ca
  
3ef2ca
!   " Build an expression that detects whether the current cursor position is in
3ef2ca
!   " certain syntax types (string, comment, etc.), for use as searchpairpos()'s
3ef2ca
!   " skip argument.
3ef2ca
    " We match "escape" for special items, such as lispEscapeSpecial.
3ef2ca
!   let s_skip = '!empty(filter(map(synstack(line("."), col(".")), ''synIDattr(v:val, "name")''), ' .
3ef2ca
! 	\ '''v:val =~? "string\\|character\\|singlequote\\|escape\\|comment"''))'
3ef2ca
!   " If executing the expression determines that the cursor is currently in
3ef2ca
!   " one of the syntax types, then we want searchpairpos() to find the pair
3ef2ca
!   " within those syntax types (i.e., not skip).  Otherwise, the cursor is
3ef2ca
!   " outside of the syntax types and s_skip should keep its value so we skip any
3ef2ca
!   " matching pair inside the syntax types.
3ef2ca
    execute 'if' s_skip '| let s_skip = 0 | endif'
3ef2ca
  
3ef2ca
    " Limit the search to lines visible in the window.
3ef2ca
***************
3ef2ca
*** 147,153 ****
3ef2ca
    endtry
3ef2ca
  
3ef2ca
    if before > 0
3ef2ca
!     call winrestview(save_cursor)
3ef2ca
    endif
3ef2ca
  
3ef2ca
    " If a match is found setup match highlighting.
3ef2ca
--- 161,171 ----
3ef2ca
    endtry
3ef2ca
  
3ef2ca
    if before > 0
3ef2ca
!     if has_getcurpos
3ef2ca
!       call setpos('.', save_cursor)
3ef2ca
!     else
3ef2ca
!       call winrestview(save_cursor)
3ef2ca
!     endif
3ef2ca
    endif
3ef2ca
  
3ef2ca
    " If a match is found setup match highlighting.
3ef2ca
*** ../vim-7.4.396/src/version.c	2014-08-06 18:17:03.475147780 +0200
3ef2ca
--- src/version.c	2014-08-06 19:06:44.627126354 +0200
3ef2ca
***************
3ef2ca
*** 743,744 ****
3ef2ca
--- 743,746 ----
3ef2ca
  {   /* Add new patch number below this line */
3ef2ca
+ /**/
3ef2ca
+     397,
3ef2ca
  /**/
3ef2ca
3ef2ca
-- 
3ef2ca
Often you're less important than your furniture.  If you think about it, you
3ef2ca
can get fired but your furniture stays behind, gainfully employed at the
3ef2ca
company that didn't need _you_ anymore.
3ef2ca
				(Scott Adams - The Dilbert principle)
3ef2ca
3ef2ca
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
3ef2ca
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
3ef2ca
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
3ef2ca
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///