To: vim_dev@googlegroups.com
Subject: Patch 8.1.0143
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 8.1.0143
Problem:    Matchit and matchparen don't handle E363.
Solution:   Catch the E363 error. (Christian Brabandt)
Files:	    runtime/pack/dist/opt/matchit/plugin/matchit.vim,
            runtime/plugin/matchparen.vim


*** ../vim-8.1.0142/runtime/pack/dist/opt/matchit/plugin/matchit.vim	2017-09-15 22:24:05.000000000 +0200
--- runtime/pack/dist/opt/matchit/plugin/matchit.vim	2018-07-03 18:08:21.939478130 +0200
***************
*** 1,5 ****
  "  matchit.vim: (global plugin) Extended "%" matching
! "  Last Change: 2017 Sep 15
  "  Maintainer:  Benji Fisher PhD   <benji@member.AMS.org>
  "  Version:     1.13.3, for Vim 6.3+
  "		Fix from Fernando Torres included.
--- 1,5 ----
  "  matchit.vim: (global plugin) Extended "%" matching
! "  Last Change: 2018 Jul 3 by Christian Brabandt
  "  Maintainer:  Benji Fisher PhD   <benji@member.AMS.org>
  "  Version:     1.13.3, for Vim 6.3+
  "		Fix from Fernando Torres included.
***************
*** 272,278 ****
    "   execute "normal!" . curcol . "l"
    " endif
    if skip =~ 'synID' && !(has("syntax") && exists("g:syntax_on"))
!     let skip = "0"
    else
      execute "if " . skip . "| let skip = '0' | endif"
    endif
--- 272,278 ----
    "   execute "normal!" . curcol . "l"
    " endif
    if skip =~ 'synID' && !(has("syntax") && exists("g:syntax_on"))
!     let skip = '0'
    else
      execute "if " . skip . "| let skip = '0' | endif"
    endif
***************
*** 719,728 ****
    let openpat = substitute(openpat, ',', '\\|', 'g')
    let closepat = substitute(close, '\(\\\@<!\(\\\\\)*\)\@<=\\(', '\\%(', 'g')
    let closepat = substitute(closepat, ',', '\\|', 'g')
    if skip =~ 'synID' && !(has("syntax") && exists("g:syntax_on"))
      let skip = '0'
    else
!     execute "if " . skip . "| let skip = '0' | endif"
    endif
    mark '
    while level
--- 719,734 ----
    let openpat = substitute(openpat, ',', '\\|', 'g')
    let closepat = substitute(close, '\(\\\@<!\(\\\\\)*\)\@<=\\(', '\\%(', 'g')
    let closepat = substitute(closepat, ',', '\\|', 'g')
+ 
    if skip =~ 'synID' && !(has("syntax") && exists("g:syntax_on"))
      let skip = '0'
    else
!     try
!       execute "if " . skip . "| let skip = '0' | endif"
!     catch /^Vim\%((\a\+)\)\=:E363/
!       " We won't find anything, so skip searching, should keep Vim responsive.
!       return
!     endtry
    endif
    mark '
    while level
*** ../vim-8.1.0142/runtime/plugin/matchparen.vim	2018-06-25 00:05:55.897799652 +0200
--- runtime/plugin/matchparen.vim	2018-07-03 18:14:30.337154571 +0200
***************
*** 1,6 ****
  " Vim plugin for showing matching parens
  " Maintainer:  Bram Moolenaar <Bram@vim.org>
! " Last Change: 2017 Sep 30
  
  " 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: 2018 Jul 3
  
  " Exit quickly when:
  " - this plugin was already loaded (or disabled)
***************
*** 103,120 ****
      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.
    let stoplinebottom = line('w$')
--- 103,130 ----
      call cursor(c_lnum, c_col - before)
    endif
  
!   if !has("syntax") || !exists("g:syntax_on")
!     let s_skip = "0"
!   else
!     " 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.
!     " Catch if this throws E363: pattern uses more memory than 'maxmempattern'.
!     try
!       execute 'if ' . s_skip . ' | let s_skip = "0" | endif'
!     catch /^Vim\%((\a\+)\)\=:E363/
!       " We won't find anything, so skip searching, should keep Vim responsive.
!       return
!     endtry
!   endif
  
    " Limit the search to lines visible in the window.
    let stoplinebottom = line('w$')
*** ../vim-8.1.0142/src/version.c	2018-07-03 17:16:55.626135028 +0200
--- src/version.c	2018-07-03 18:16:06.620560417 +0200
***************
*** 791,792 ****
--- 791,794 ----
  {   /* Add new patch number below this line */
+ /**/
+     143,
  /**/

-- 
If Microsoft would build a car...
... Occasionally, executing a maneuver such as a left turn
would cause your car to shut down and refuse to restart, in
which case you would have to reinstall the engine.

 /// 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    ///