Skip to content

Commit 5ba6eab

Browse files
authored
case-sensitivity (#583)
* case-sensitivity
1 parent a328e81 commit 5ba6eab

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

indent/javascript.vim

+14-14
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ else
3838
endif
3939

4040
let s:line_pre = '^\s*\%(\/\*.*\*\/\s*\)*'
41-
let s:expr_case = s:line_pre . '\%(\%(case\>.*\)\|default\)\s*:\C'
41+
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 = '\%(string\|regex\|special\|doc\|comment\|template\)\c'
43+
let s:syng_strcom = '\%(string\|regex\|special\|doc\|comment\|template\)'
4444

4545
" Regex of syntax group names that are strings or documentation.
46-
let s:syng_comment = '\%(comment\|doc\)\c'
46+
let s:syng_comment = '\%(comment\|doc\)'
4747

4848
" Expression used to check whether we should skip a match with searchpair().
4949
let s:skip_expr = "line('.') < (prevnonblank(v:lnum) - 2000) ? dummy : s:IsSyn(line('.'),col('.'),'')"
@@ -60,23 +60,23 @@ let s:line_term = '\s*\%(\/\*.*\*\/\s*\)*$'
6060

6161
" configurable regexes that define continuation lines, not including (, {, or [.
6262
if !exists('g:javascript_opfirst')
63-
let g:javascript_opfirst = '\%([<>,:?^%]\|\([-/.+]\)\%(\1\|\*\|\/\)\@!\|\*\/\@!\|=>\@!\||\|&\|in\%(stanceof\)\=\>\)\C'
63+
let g:javascript_opfirst = '\%([<>,:?^%]\|\([-/.+]\)\%(\1\|\*\|\/\)\@!\|\*\/\@!\|=>\@!\||\|&\|in\%(stanceof\)\=\>\)'
6464
endif
6565
let g:javascript_opfirst = s:line_pre . g:javascript_opfirst
6666

6767
if !exists('g:javascript_continuation')
68-
let g:javascript_continuation = '\%([<*,.?:^%]\|+\@<!+\|-\@<!-\|=\@<!>\|\*\@<!\/\|=\||\|&\|\<in\%(stanceof\)\=\)\C'
68+
let g:javascript_continuation = '\%([<*,.?:^%]\|+\@<!+\|-\@<!-\|=\@<!>\|\*\@<!\/\|=\||\|&\|\<in\%(stanceof\)\=\)'
6969
endif
7070
let g:javascript_continuation .= s:line_term
7171

7272
function s:Onescope(lnum,text,add)
73-
return a:text =~ '\%(\<else\|\<do\|=>' . (a:add ? '\|\<try\|\<finally' : '' ) . '\)\C' . s:line_term ||
73+
return a:text =~# '\%(\<else\|\<do\|=>' . (a:add ? '\|\<try\|\<finally' : '' ) . '\)' . s:line_term ||
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 &&
77-
\ search((a:add ? '\%(function\*\|[A-Za-z_$][0-9A-Za-z_$]*\)\C' :
78-
\ '\<\%(for\%(\s+each\)\=\|if\|let\|while\|with\)\C') . '\_s*\%#','bW') &&
79-
\ (a:add || (expand("<cword>") == 'while' ? !s:lookForParens('\<do\>\C', '\<while\>\C','bW',100) : 1))
77+
\ search((a:add ? '\%(function\*\|[A-Za-z_$][0-9A-Za-z_$]*\)' :
78+
\ '\<\%(for\%(\s+each\)\=\|if\|let\|while\|with\)') . '\_s*\%#\C','bW') &&
79+
\ (a:add || (expand("<cword>") ==# 'while' ? !s:lookForParens('\<do\>\C', '\<while\>\C','bW',100) : 1))
8080
endfunction
8181

8282
" Auxiliary Functions {{{2
@@ -151,7 +151,7 @@ function GetJavascriptIndent()
151151
endif
152152
let line = s:StripLine(line)
153153

154-
if (line =~ s:expr_case)
154+
if (line =~# s:expr_case)
155155
let cpo_switch = &cpo
156156
set cpo+=%
157157
let ind = cindent(v:lnum)
@@ -187,13 +187,13 @@ function GetJavascriptIndent()
187187
return indent(num)
188188
endif
189189
let inb = num == 0 ? 1 : s:Onescope(num, s:StripLine(strpart(getline(num),0,b:js_cache[2] - 1)),1)
190-
let switch_offset = (!inb || num == 0) || expand("<cword>") != 'switch' ? 0 : &cino !~ ':' || !has('float') ? s:sw() :
190+
let switch_offset = (!inb || num == 0) || expand("<cword>") !=# 'switch' ? 0 : &cino !~ ':' || !has('float') ? s:sw() :
191191
\ float2nr(str2float(matchstr(&cino,'.*:\zs[-0-9.]*')) * (match(&cino,'.*:\zs[^,]*s') ? s:sw() : 1))
192192
let pline = s:StripLine(getline(lnum))
193-
if ((line =~ g:javascript_opfirst ||
194-
\ (pline =~ g:javascript_continuation && pline !~ s:expr_case &&
193+
if ((line =~# g:javascript_opfirst ||
194+
\ (pline =~# g:javascript_continuation && pline !~# s:expr_case &&
195195
\ (pline !~ ':' . s:line_term || line !~# s:line_pre .
196-
\ '\%(debugger\|do\|else\|finally\|for\|if\|let\|switch\|throw\|try\|while\|with\)'))) &&
196+
\ '\%(debugger\|do\|else\|finally\|for\|if\|let\|switch\|throw\|try\|while\|with\)\>'))) &&
197197
\ inb) || (s:Onescope(lnum,pline,0) && line !~ s:line_pre . '{')
198198
return (num > 0 ? indent(num) : -s:sw()) + (s:sw() * 2) + switch_offset
199199
elseif num > 0

0 commit comments

Comments
 (0)