diff --git a/indent/javascript.vim b/indent/javascript.vim index 4dbf5d88..faf592b3 100644 --- a/indent/javascript.vim +++ b/indent/javascript.vim @@ -71,20 +71,19 @@ endif let g:javascript_opfirst = s:line_pre . g:javascript_opfirst let g:javascript_continuation .= s:line_term -function s:OneScope(lnum,text,add) +function s:OneScope(lnum,text) return a:text =~# '\%(\\)' . s:line_term ? 'no b' : - \ ((a:add && a:text =~ s:line_pre . '$' && search('\%' . s:PrevCodeLine(a:lnum - 1) . 'l.)' . s:line_term)) || - \ cursor(a:lnum, match(a:text, ')' . s:line_term)) > -1) && - \ s:GetPair('(', ')', 'cbW', 100) > 0 && search('\C\l\+\_s*\%#','bW') && - \ (a:add || ((expand('') !=# 'while' || !s:GetPair('\C\', '\C\','nbW',100)) && - \ (expand('') !=# 'each' || search('\C\') : '' + \ cursor(a:lnum, match(' ' . a:text, ')' . s:line_term)) > -1 && + \ s:GetPair('(', ')', 'bW', 100) > 0 && search('\C\l\+\_s*\%#','bW') && + \ (expand('') !=# 'while' || s:GetPair('\C\', '\C\','nbW',100) <= 0) && + \ (expand('') !=# 'each' || search('\C\') : '' endfunction " https://github.com/sweet-js/sweet.js/wiki/design#give-lookbehind-to-the-reader function s:IsBlock() return getline(line('.'))[col('.')-1] == '{' && !search( \ '\C\%(\\|\*\@ 0 && search('\C\' && + \ s:OneScope(l:lnum,pline) =~# '\<\%(for\|each\|if\|let\|no\sb\|w\%(hile\|ith\)\)\>' && \ l:line !~ s:line_pre . '{' return (num > 0 ? indent(num) : -s:sw()) + (s:sw() * 2) + switch_offset elseif num > 0