Skip to content

Commit bedb8cb

Browse files
authored
cleaning
1 parent 6f3e6e9 commit bedb8cb

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,13 +37,14 @@ else
3737
endfunction
3838
endif
3939

40-
let s:expr_case = '\<\%(\%(case\>\s*[^[:blank:]:].\{-}\)\|default\)\s*:\C'
40+
let s:case_stmt = '\<\%(\%(case\>\s*[^[:blank:]:].\{-}\)\|default\)\s*:\C'
41+
4142
" Regex of syntax group names that are or delimit string or are comments.
4243
let s:syng_strcom = '\%(s\%(tring\|pecial\)\|comment\|regex\|doc\|template\)'
4344
" Expression used to check whether we should skip a match with searchpair().
4445
let s:skip_expr = "synIDattr(synID(line('.'),col('.'),0),'name') =~? '".s:syng_strcom."'"
4546
function s:skip_func(lnum)
46-
if !s:free || search('`','nW',a:lnum) || search('\*\/','nW',a:lnum)
47+
if !s:free || search('`\|\%(\*\/\)','nW',a:lnum)
4748
let s:free = !eval(s:skip_expr . " . '\\|html'")
4849
let s:looksyn = s:free ? line('.') : s:looksyn
4950
return !s:free
@@ -145,7 +146,7 @@ function s:IsBlock(...)
145146
elseif char == '>'
146147
return getline('.')[col('.')-2] == '=' || syn =~? '^jsflow'
147148
elseif char == ':'
148-
return cursor(0,match(' ' . strpart(getline('.'),0,col('.')),'.*\zs' . s:expr_case . '$')) + 1 &&
149+
return cursor(0,match(' ' . strpart(getline('.'),0,col('.')),'.*\zs' . s:case_stmt . '$')) + 1 &&
149150
\ (expand('<cword>') !=# 'default' || s:previous_token() !~ '[,{]')
150151
endif
151152
return index(split('return const let import export yield default delete var void typeof throw new in instanceof'
@@ -244,10 +245,10 @@ function GetJavascriptIndent()
244245
if s:current_char() == ')' && s:GetPair('(', ')', 'bW', s:skip_expr, 100) > 0 && s:previous_token() ==# 'switch'
245246
let switch_offset = &cino !~ ':' || !has('float') ? s:W :
246247
\ float2nr(str2float(matchstr(&cino,'.*:\zs[-0-9.]*')) * (&cino =~# '.*:[^,]*s' ? s:W : 1))
247-
if l:line =~# '^' . s:expr_case
248+
if l:line =~# '^' . s:case_stmt
248249
return indent(num) + switch_offset
249250
endif
250-
let stmt = pline !~# s:expr_case . '$'
251+
let stmt = pline !~# s:case_stmt . '$'
251252
endif
252253
endif
253254

0 commit comments

Comments
 (0)