From 09dca6defa9e4592083670d758b28e1b29324753 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Yngve=20Lerv=C3=A5g?= Date: Sat, 2 Nov 2013 17:46:43 +0100 Subject: [PATCH] Fixed stupid bug in motion.vim --- autoload/latex/motion.vim | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/autoload/latex/motion.vim b/autoload/latex/motion.vim index 8583185..79a70c6 100644 --- a/autoload/latex/motion.vim +++ b/autoload/latex/motion.vim @@ -352,6 +352,37 @@ function! s:highlight_matching_pair(...) endfor endif endfunction + +" {{{1 s:search_and_skip_comments +function! s:search_and_skip_comments(pat, ...) + " Usage: s:search_and_skip_comments(pat, [flags, stopline]) + let flags = a:0 >= 1 ? a:1 : '' + let stopline = a:0 >= 2 ? a:2 : 0 + let saved_pos = getpos('.') + + " search once + let ret = search(a:pat, flags, stopline) + + if ret + " do not match at current position if inside comment + let flags = substitute(flags, 'c', '', 'g') + + " keep searching while in comment + while latex#util#in_comment() + let ret = search(a:pat, flags, stopline) + if !ret + break + endif + endwhile + endif + + if !ret + " if no match found, restore position + call setpos('.', saved_pos) + endif + + return ret +endfunction " }}}1 " vim:fdm=marker:ff=unix