From 0a22e6d46dd6ff9f75c21e826ec961bc1526239c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Yngve=20Lerv=C3=A5g?= Date: Sat, 17 Sep 2016 22:24:20 +0200 Subject: [PATCH] Fix #559: Proper handling of ampersands --- indent/tex.vim | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/indent/tex.vim b/indent/tex.vim index b9b9ee0..ae0af7a 100644 --- a/indent/tex.vim +++ b/indent/tex.vim @@ -44,7 +44,7 @@ function! VimtexIndent(lnum) " {{{1 return indent(a:lnum) endif - let l:nprev = s:get_prev_line(l:nprev) + let l:nprev = s:get_prev_line(l:nprev, 'ignore-ampersands') if l:nprev == 0 | return 0 | endif let l:prev = getline(l:nprev) @@ -56,12 +56,15 @@ function! VimtexIndent(lnum) " {{{1 endfunction "}}} -function! s:get_prev_line(lnum) " {{{1 +function! s:get_prev_line(lnum, ...) " {{{1 + let l:ignore_amps = a:0 > 0 let l:lnum = a:lnum let l:prev = getline(l:lnum) while l:lnum != 0 - \ && (l:prev =~# '^\s*%' || s:is_verbatim(l:prev, l:lnum)) + \ && (l:prev =~# '^\s*%' + \ || s:is_verbatim(l:prev, l:lnum) + \ || !l:ignore_amps && match(l:prev, '^\s*&') >= 0) let l:lnum = prevnonblank(l:lnum - 1) let l:prev = getline(l:lnum) endwhile