diff --git a/autoload/vimtex/delim.vim b/autoload/vimtex/delim.vim index 2d6b66d..2d6a90f 100644 --- a/autoload/vimtex/delim.vim +++ b/autoload/vimtex/delim.vim @@ -407,9 +407,9 @@ function! s:get_delim(direction, type, side) " {{{1 " let l:re = s:re[a:type][a:side] let [l:lnum, l:cnum] = a:direction ==# 'next' - \ ? searchpos(l:re, 'cnW', line('w$')) + \ ? searchpos(l:re, 'cnW', line('w$') + 200) \ : a:direction ==# 'prev' - \ ? searchpos(l:re, 'bcnW', line('w0')) + \ ? searchpos(l:re, 'bcnW', max([line('w0') - 200, 1])) \ : searchpos(l:re, 'bcnW', line('.')) let l:match = matchstr(getline(l:lnum), '^' . l:re, l:cnum-1) @@ -625,8 +625,8 @@ endfunction function! s:get_matching_env() dict " {{{1 let [re, flags, stopline] = self.is_open - \ ? [self.re.close, 'nW', line('w$')] - \ : [self.re.open, 'bnW', line('w0')] + \ ? [self.re.close, 'nW', line('w$') + 200] + \ : [self.re.open, 'bnW', max([line('w0') - 200, 1])] let [lnum, cnum] = searchpairpos(self.re.open, '', self.re.close, \ flags, '', stopline) @@ -638,8 +638,8 @@ endfunction " }}}1 function! s:get_matching_tex() dict " {{{1 let [re, flags, stopline] = self.is_open - \ ? [self.re.open, 'nW', line('w$')] - \ : [self.re.open, 'bnW', line('w0')] + \ ? [self.re.open, 'nW', line('w$') + 200] + \ : [self.re.open, 'bnW', max([line('w0') - 200, 1])] let [lnum, cnum] = searchpos(re, flags, stopline) let match = matchstr(getline(lnum), '^' . re, cnum-1) @@ -650,8 +650,8 @@ endfunction " }}}1 function! s:get_matching_latex() dict " {{{1 let [re, flags, stopline] = self.is_open - \ ? [self.re.close, 'nW', line('w$')] - \ : [self.re.open, 'bnW', line('w0')] + \ ? [self.re.close, 'nW', line('w$') + 200] + \ : [self.re.open, 'bnW', max([line('w0') - 200, 1])] let [lnum, cnum] = searchpos(re, flags, stopline) let match = matchstr(getline(lnum), '^' . re, cnum-1) @@ -662,8 +662,8 @@ endfunction " }}}1 function! s:get_matching_delim() dict " {{{1 let [re, flags, stopline] = self.is_open - \ ? [self.re.close, 'nW', line('w$')] - \ : [self.re.open, 'bnW', line('w0')] + \ ? [self.re.close, 'nW', line('w$') + 200] + \ : [self.re.open, 'bnW', max([line('w0') - 200, 1])] let [lnum, cnum] = searchpairpos(self.re.open, '', self.re.close, \ flags, '', stopline)