diff options
Diffstat (limited to 'vim/indent')
-rw-r--r-- | vim/indent/perl.vim | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/vim/indent/perl.vim b/vim/indent/perl.vim index f02f2a65..14a211f5 100644 --- a/vim/indent/perl.vim +++ b/vim/indent/perl.vim @@ -35,31 +35,32 @@ function! GetPerlIndent(lnum) return 0 endif - " Heredoc and POD detection; start at top of buffer + " Heredoc and POD detection; this is expensive, so limit it to 512 lines of + " context + let l:lim = 512 + let l:hpn = line('$') > l:lim + \ ? line('$') - l:lim + \ : 0 let l:pod = 0 - let l:hpn = 0 while l:hpn < a:lnum let l:hpl = getline(l:hpn) " If we're not in a heredoc and not in a comment ... if !exists('l:hpw') && l:hpl !~# '^\s*#' - " POD switching - if !l:pod && stridx(l:hpl, '=pod') == 0 + " POD switching; match any section so that we can handle long PODs + if !l:pod && l:hpl =~# '^=\l\+\d\?\>' let l:pod = 1 elseif l:pod && stridx(l:hpl, '=cut') == 0 let l:pod = 0 - else - " Line opens with a heredoc + " Heredoc switch on + else let l:hpm = matchstr(l:hpl, s:heredoc_open) - - " Store the heredoc word and make this our indent reference if strlen(l:hpm) let l:hpw = matchstr(l:hpm, s:heredoc_word) let l:pn = l:hpn endif - endif " If we are in a heredoc and we found the token word, finish it |