Skip to content

Commit 6de8f62

Browse files
authored
more regex
1 parent 4278caa commit 6de8f62

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

indent/javascript.vim

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ else
3737
endfunction
3838
endif
3939

40-
let s:line_pre = '^\s*\%(\/\*.*\*\/\s*\)*'
40+
let s:line_pre = '^\s*\%(\/\*.\{-}\*\/\s*\)*'
4141
let s:expr_case = s:line_pre . '\%(\%(case\>.*\)\|default\)\s*:'
4242
" Regex of syntax group names that are or delimit string or are comments.
43-
let s:syng_strcom = '\%(s\%(tring\|pecial\)\|regex\|doc\|comment\|template\)'
43+
let s:syng_strcom = '\%(s\%(tring\|pecial\)\|comment\|regex\|doc\|template\)'
4444

4545
" Regex of syntax group names that are strings or documentation.
4646
let s:syng_comment = '\%(comment\|doc\)'
@@ -56,7 +56,7 @@ function s:lookForParens(start,end,flags,time)
5656
endtry
5757
endfunction
5858

59-
let s:line_term = '\s*\%(\/\*.*\*\/\s*\)*$'
59+
let s:line_term = '\s*\%(\/\*.\{-}\*\/\s*\)*$'
6060

6161
" configurable regexes that define continuation lines, not including (, {, or [.
6262
if !exists('g:javascript_opfirst')
@@ -74,7 +74,8 @@ function s:Onescope(lnum,text,add)
7474
\ ((a:add && a:text =~ s:line_pre . s:line_term && search('\%' . s:PrevCodeLine(a:lnum - 1) . 'l.)' . s:line_term)) ||
7575
\ cursor(a:lnum, match(a:text, ')' . s:line_term)) > -1) &&
7676
\ s:lookForParens('(', ')', 'cbW', 100) > 0 && search((a:add ?
77-
\ '\%(function\*\|[[:lower:][:upper:]_$][[:digit:][:lower:][:upper:]_$]*\)' : '\<\%(for\%(\s+each\)\=\|if\|let\|w\%(hile\|ith\)\)') . '\_s*\%#\C','bW') &&
77+
\ '\%(function\*\|[[:lower:][:upper:]_$][[:digit:][:lower:][:upper:]_$]*\)' :
78+
\ '\<\%(for\%(\s+each\)\=\|if\|let\|w\%(hile\|ith\)\)') . '\_s*\%#\C','bW') &&
7879
\ (a:add || (expand("<cword>") ==# 'while' ? !s:lookForParens('\<do\>\C', '\<while\>\C','bW',100) : 1))
7980
endfunction
8081

@@ -192,7 +193,7 @@ function GetJavascriptIndent()
192193
if ((line =~# g:javascript_opfirst ||
193194
\ (pline =~# g:javascript_continuation && pline !~# s:expr_case &&
194195
\ (pline !~ ':' . s:line_term || line !~#
195-
\ s:line_pre . '\%(d\%(ebugger\|o\)\|else\|f\%(inally\|or\)\|if\|let\|switch\|t\%(hrow\|ry\)\|w\%(hile\|ith\)\)\>'))) &&
196+
\ s:line_pre . '\%(d\%(o\|ebugger\)\|else\|f\%(or\|inally\)\|if\|let\|switch\|t\%(hrow\|ry\)\|w\%(hile\|ith\)\)\>'))) &&
196197
\ inb) || (s:Onescope(lnum,pline,0) && line !~ s:line_pre . '{')
197198
return (num > 0 ? indent(num) : -s:sw()) + (s:sw() * 2) + switch_offset
198199
elseif num > 0

0 commit comments

Comments
 (0)