cc1a1dc
To: vim-dev@vim.org
cc1a1dc
Subject: Patch 7.1.269
cc1a1dc
Fcc: outbox
cc1a1dc
From: Bram Moolenaar <Bram@moolenaar.net>
cc1a1dc
Mime-Version: 1.0
cc1a1dc
Content-Type: text/plain; charset=ISO-8859-1
cc1a1dc
Content-Transfer-Encoding: 8bit
cc1a1dc
------------
cc1a1dc
cc1a1dc
Patch 7.1.269
cc1a1dc
Problem:    The matchparen plugin has an arbitrary limit for the number of
cc1a1dc
	    lines to look for a match.
cc1a1dc
Solution:   Rely on the searchpair() timeout.
cc1a1dc
Files:	    runtime/plugin/matchparen.vim
cc1a1dc
cc1a1dc
cc1a1dc
*** ../vim-7.1.268/runtime/plugin/matchparen.vim	Sun Jan  6 20:05:36 2008
cc1a1dc
--- runtime/plugin/matchparen.vim	Wed Feb 27 22:39:32 2008
cc1a1dc
***************
cc1a1dc
*** 1,6 ****
cc1a1dc
  " Vim plugin for showing matching parens
cc1a1dc
  " Maintainer:  Bram Moolenaar <Bram@vim.org>
cc1a1dc
! " Last Change: 2008 Jan 06
cc1a1dc
  
cc1a1dc
  " Exit quickly when:
cc1a1dc
  " - this plugin was already loaded (or disabled)
cc1a1dc
--- 1,6 ----
cc1a1dc
  " Vim plugin for showing matching parens
cc1a1dc
  " Maintainer:  Bram Moolenaar <Bram@vim.org>
cc1a1dc
! " Last Change: 2008 Feb 27
cc1a1dc
  
cc1a1dc
  " Exit quickly when:
cc1a1dc
  " - this plugin was already loaded (or disabled)
cc1a1dc
***************
cc1a1dc
*** 34,40 ****
cc1a1dc
    endif
cc1a1dc
  
cc1a1dc
    " Avoid that we remove the popup menu.
cc1a1dc
!   if pumvisible()
cc1a1dc
      return
cc1a1dc
    endif
cc1a1dc
  
cc1a1dc
--- 34,41 ----
cc1a1dc
    endif
cc1a1dc
  
cc1a1dc
    " Avoid that we remove the popup menu.
cc1a1dc
!   " Return when there are no colors (looks like the cursor jumps).
cc1a1dc
!   if pumvisible() || (&t_Co < 8 && !has("gui_running"))
cc1a1dc
      return
cc1a1dc
    endif
cc1a1dc
  
cc1a1dc
***************
cc1a1dc
*** 60,98 ****
cc1a1dc
    endif
cc1a1dc
  
cc1a1dc
    " Figure out the arguments for searchpairpos().
cc1a1dc
-   " Restrict the search to visible lines with "stopline".
cc1a1dc
-   " And avoid searching very far (e.g., for closed folds and long lines)
cc1a1dc
-   " The "viewable" variables give a range in which we can scroll while keeping
cc1a1dc
-   " the cursor at the same position
cc1a1dc
-   " adjustedScrolloff accounts for very large numbers of scrolloff
cc1a1dc
-   let adjustedScrolloff = min([&scrolloff, (line('w$') - line('w0')) / 2])
cc1a1dc
-   let bottom_viewable = min([line('$'), c_lnum + &lines - adjustedScrolloff - 2])
cc1a1dc
-   let top_viewable = max([1, c_lnum-&lines+adjustedScrolloff + 2])
cc1a1dc
-   " one of these stoplines will be adjusted below, but the current values are
cc1a1dc
-   " minimal boundaries within the current window
cc1a1dc
-   let stoplinebottom = line('w$')
cc1a1dc
-   let stoplinetop = line('w0')
cc1a1dc
    if i % 2 == 0
cc1a1dc
      let s_flags = 'nW'
cc1a1dc
      let c2 = plist[i + 1]
cc1a1dc
-     if has("byte_offset") && has("syntax_items") && &smc > 0
cc1a1dc
-       let stopbyte = min([line2byte("$"), line2byte(".") + col(".") + &smc * 2])
cc1a1dc
-       let stopline = min([bottom_viewable, byte2line(stopbyte)])
cc1a1dc
-     else
cc1a1dc
-       let stopline = min([bottom_viewable, c_lnum + 100])
cc1a1dc
-     endif
cc1a1dc
-     let stoplinebottom = stopline
cc1a1dc
    else
cc1a1dc
      let s_flags = 'nbW'
cc1a1dc
      let c2 = c
cc1a1dc
      let c = plist[i - 1]
cc1a1dc
-     if has("byte_offset") && has("syntax_items") && &smc > 0
cc1a1dc
-       let stopbyte = max([1, line2byte(".") + col(".") - &smc * 2])
cc1a1dc
-       let stopline = max([top_viewable, byte2line(stopbyte)])
cc1a1dc
-     else
cc1a1dc
-       let stopline = max([top_viewable, c_lnum - 100])
cc1a1dc
-     endif
cc1a1dc
-     let stoplinetop = stopline
cc1a1dc
    endif
cc1a1dc
    if c == '['
cc1a1dc
      let c = '\['
cc1a1dc
--- 61,73 ----
cc1a1dc
***************
cc1a1dc
*** 111,120 ****
cc1a1dc
  	\ '=~?  "string\\|character\\|singlequote\\|comment"'
cc1a1dc
    execute 'if' s_skip '| let s_skip = 0 | endif'
cc1a1dc
  
cc1a1dc
    try
cc1a1dc
!     " Limit the search time to 500 msec to avoid a hang on very long lines.
cc1a1dc
!     let [m_lnum, m_col] = searchpairpos(c, '', c2, s_flags, s_skip, stopline, 500)
cc1a1dc
    catch /E118/
cc1a1dc
      let [m_lnum, m_col] = searchpairpos(c, '', c2, s_flags, s_skip, stopline)
cc1a1dc
    endtry
cc1a1dc
  
cc1a1dc
--- 86,132 ----
cc1a1dc
  	\ '=~?  "string\\|character\\|singlequote\\|comment"'
cc1a1dc
    execute 'if' s_skip '| let s_skip = 0 | endif'
cc1a1dc
  
cc1a1dc
+   " Limit the search to lines visible in the window.
cc1a1dc
+   let stoplinebottom = line('w$')
cc1a1dc
+   let stoplinetop = line('w0')
cc1a1dc
+   if i % 2 == 0
cc1a1dc
+     let stopline = stoplinebottom
cc1a1dc
+   else
cc1a1dc
+     let stopline = stoplinetop
cc1a1dc
+   endif
cc1a1dc
+ 
cc1a1dc
    try
cc1a1dc
!     " Limit the search time to 300 msec to avoid a hang on very long lines.
cc1a1dc
!     " This fails when a timeout is not supported.
cc1a1dc
!     let [m_lnum, m_col] = searchpairpos(c, '', c2, s_flags, s_skip, stopline, 300)
cc1a1dc
    catch /E118/
cc1a1dc
+     " Can't use the timeout, restrict the stopline a bit more to avoid taking
cc1a1dc
+     " a long time on closed folds and long lines.
cc1a1dc
+     " The "viewable" variables give a range in which we can scroll while
cc1a1dc
+     " keeping the cursor at the same position.
cc1a1dc
+     " adjustedScrolloff accounts for very large numbers of scrolloff.
cc1a1dc
+     let adjustedScrolloff = min([&scrolloff, (line('w$') - line('w0')) / 2])
cc1a1dc
+     let bottom_viewable = min([line('$'), c_lnum + &lines - adjustedScrolloff - 2])
cc1a1dc
+     let top_viewable = max([1, c_lnum-&lines+adjustedScrolloff + 2])
cc1a1dc
+     " one of these stoplines will be adjusted below, but the current values are
cc1a1dc
+     " minimal boundaries within the current window
cc1a1dc
+     if i % 2 == 0
cc1a1dc
+       if has("byte_offset") && has("syntax_items") && &smc > 0
cc1a1dc
+ 	let stopbyte = min([line2byte("$"), line2byte(".") + col(".") + &smc * 2])
cc1a1dc
+ 	let stopline = min([bottom_viewable, byte2line(stopbyte)])
cc1a1dc
+       else
cc1a1dc
+ 	let stopline = min([bottom_viewable, c_lnum + 100])
cc1a1dc
+       endif
cc1a1dc
+       let stoplinebottom = stopline
cc1a1dc
+     else
cc1a1dc
+       if has("byte_offset") && has("syntax_items") && &smc > 0
cc1a1dc
+ 	let stopbyte = max([1, line2byte(".") + col(".") - &smc * 2])
cc1a1dc
+ 	let stopline = max([top_viewable, byte2line(stopbyte)])
cc1a1dc
+       else
cc1a1dc
+ 	let stopline = max([top_viewable, c_lnum - 100])
cc1a1dc
+       endif
cc1a1dc
+       let stoplinetop = stopline
cc1a1dc
+     endif
cc1a1dc
      let [m_lnum, m_col] = searchpairpos(c, '', c2, s_flags, s_skip, stopline)
cc1a1dc
    endtry
cc1a1dc
  
cc1a1dc
*** ../vim-7.1.268/src/version.c	Sun Mar  9 14:30:12 2008
cc1a1dc
--- src/version.c	Sun Mar  9 16:21:00 2008
cc1a1dc
***************
cc1a1dc
*** 668,669 ****
cc1a1dc
--- 668,671 ----
cc1a1dc
  {   /* Add new patch number below this line */
cc1a1dc
+ /**/
cc1a1dc
+     269,
cc1a1dc
  /**/
cc1a1dc
cc1a1dc
-- 
cc1a1dc
hundred-and-one symptoms of being an internet addict:
cc1a1dc
93. New mail alarm on your palmtop annoys other churchgoers.
cc1a1dc
cc1a1dc
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
cc1a1dc
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
cc1a1dc
\\\        download, build and distribute -- http://www.A-A-P.org        ///
cc1a1dc
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///