aboutsummaryrefslogtreecommitdiff
path: root/vim/indent
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-07-07 14:34:55 +1200
committerTom Ryder <tom@sanctum.geek.nz>2018-07-07 14:34:55 +1200
commitf125d0bc8b08cbb9e77bd1b64e189909821239d1 (patch)
tree2baeb179e521c4a2a86d3aac2af6730ca980ce75 /vim/indent
parent343553c05b647cf9716eb9bd44cf023fac61fc61 (diff)
downloaddotfiles-f125d0bc8b08cbb9e77bd1b64e189909821239d1.tar.gz
dotfiles-f125d0bc8b08cbb9e77bd1b64e189909821239d1.zip
Rearrange heredoc/POD indent check for speed
Diffstat (limited to 'vim/indent')
-rw-r--r--vim/indent/perl.vim19
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