astepano / rpms / vim

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