Blob Blame History Raw
To: vim-dev@vim.org
Subject: patch 7.1.048
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
------------

Patch 7.1.048
Problem:    The matchparen plugin doesn't update the match when scrolling with
	    the mouse wheel. (Ilya Bobir)
Solution:   Set the match highlighting for text that can be scrolled into the
	    viewable area without moving the cursor. (Chris Lubinski)
Files:	    runtime/plugin/matchparen.vim


*** ../vim-7.1.047/runtime/plugin/matchparen.vim	Sun May  6 14:26:16 2007
--- runtime/plugin/matchparen.vim	Mon Jul 30 21:14:06 2007
***************
*** 1,6 ****
  " Vim plugin for showing matching parens
  " Maintainer:  Bram Moolenaar <Bram@vim.org>
! " Last Change: 2006 Oct 12
  
  " 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: 2007 Jul 30
  
  " Exit quickly when:
  " - this plugin was already loaded (or disabled)
***************
*** 62,86 ****
    " Figure out the arguments for searchpairpos().
    " Restrict the search to visible lines with "stopline".
    " And avoid searching very far (e.g., for closed folds and long lines)
    if i % 2 == 0
      let s_flags = 'nW'
      let c2 = plist[i + 1]
      if has("byte_offset") && has("syntax_items") && &smc > 0
        let stopbyte = min([line2byte("$"), line2byte(".") + col(".") + &smc * 2])
!       let stopline = min([line('w$'), byte2line(stopbyte)])
      else
!       let stopline = min([line('w$'), c_lnum + 100])
      endif
    else
      let s_flags = 'nbW'
      let c2 = c
      let c = plist[i - 1]
      if has("byte_offset") && has("syntax_items") && &smc > 0
        let stopbyte = max([1, line2byte(".") + col(".") - &smc * 2])
!       let stopline = max([line('w0'), byte2line(stopbyte)])
      else
!       let stopline = max([line('w0'), c_lnum - 100])
      endif
    endif
    if c == '['
      let c = '\['
--- 62,98 ----
    " Figure out the arguments for searchpairpos().
    " Restrict the search to visible lines with "stopline".
    " And avoid searching very far (e.g., for closed folds and long lines)
+   " The "viewable" variables give a range in which we can scroll while keeping
+   " the cursor at the same position
+   " adjustedScrolloff accounts for very large numbers of scrolloff
+   let adjustedScrolloff = min([&scrolloff, (line('w$') - line('w0')) / 2])
+   let bottom_viewable = min([line('$'), c_lnum + &lines - adjustedScrolloff - 2])
+   let top_viewable = max([1, c_lnum-&lines+adjustedScrolloff + 2])
+   " one of these stoplines will be adjusted below, but the current values are
+   " minimal boundaries within the current window
+   let stoplinebottom = line('w$')
+   let stoplinetop = line('w0')
    if i % 2 == 0
      let s_flags = 'nW'
      let c2 = plist[i + 1]
      if has("byte_offset") && has("syntax_items") && &smc > 0
        let stopbyte = min([line2byte("$"), line2byte(".") + col(".") + &smc * 2])
!       let stopline = min([bottom_viewable, byte2line(stopbyte)])
      else
!       let stopline = min([bottom_viewable, c_lnum + 100])
      endif
+     let stoplinebottom = stopline
    else
      let s_flags = 'nbW'
      let c2 = c
      let c = plist[i - 1]
      if has("byte_offset") && has("syntax_items") && &smc > 0
        let stopbyte = max([1, line2byte(".") + col(".") - &smc * 2])
!       let stopline = max([top_viewable, byte2line(stopbyte)])
      else
!       let stopline = max([top_viewable, c_lnum - 100])
      endif
+     let stoplinetop = stopline
    endif
    if c == '['
      let c = '\['
***************
*** 106,112 ****
    endif
  
    " If a match is found setup match highlighting.
!   if m_lnum > 0 && m_lnum >= line('w0') && m_lnum <= line('w$')
      exe '3match MatchParen /\(\%' . c_lnum . 'l\%' . (c_col - before) .
  	  \ 'c\)\|\(\%' . m_lnum . 'l\%' . m_col . 'c\)/'
      let w:paren_hl_on = 1
--- 118,124 ----
    endif
  
    " If a match is found setup match highlighting.
!   if m_lnum > 0 && m_lnum >= stoplinetop && m_lnum <= stoplinebottom 
      exe '3match MatchParen /\(\%' . c_lnum . 'l\%' . (c_col - before) .
  	  \ 'c\)\|\(\%' . m_lnum . 'l\%' . m_col . 'c\)/'
      let w:paren_hl_on = 1
*** ../vim-7.1.047/src/version.c	Wed Aug  1 15:47:06 2007
--- src/version.c	Thu Aug  2 22:59:07 2007
***************
*** 668,669 ****
--- 668,671 ----
  {   /* Add new patch number below this line */
+ /**/
+     48,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
91. It's Saturday afternoon in the middle of May and you
    are on computer.

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///