Skip to content

Commit 50ff80a

Browse files
authored
other randoms (pangloss#1112)
1 parent 3e0b1af commit 50ff80a

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

indent/javascript.vim

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,13 @@ function s:SynAt(l,c)
8686
return s:synid_cache[1][pos]
8787
endfunction
8888

89-
function s:ParseCino(f)
90-
let [divider, n, cstr] = [0] + matchlist(&cino,
91-
\ '\%(.*,\)\=\%(\%d'.char2nr(a:f).'\(-\)\=\([.s0-9]*\)\)\=')[1:2]
89+
function g:ParseCino(f)
90+
let i = strridx(&cino,a:f)
91+
if i == -1
92+
return
93+
endif
94+
let [divider, n] = [0, &cino[i+1] == '-']
95+
let [cstr, n] = [&cino[i+n+1 : stridx(&cino,',',i)], n ? '-' : '']
9296
for c in split(cstr,'\zs')
9397
if c == '.' && !divider
9498
let divider = 1
@@ -371,7 +375,7 @@ function GetJavascriptIndent()
371375
let [l:lnum, lcol, pline] = getpos('.')[1:2] + [getline('.')[:col('.')-1]]
372376

373377
let l:line = substitute(l:line,'^\s*','','')
374-
let l:line_raw = l:line
378+
let l:line_s = l:line[0]
375379
if l:line[:1] == '/*'
376380
let l:line = substitute(l:line,'^\%(\/\*.\{-}\*\/\s*\)*','','')
377381
endif
@@ -445,7 +449,7 @@ function GetJavascriptIndent()
445449
let pval = s:ParseCino('(')
446450
if !pval
447451
let [Wval, vcol] = [s:ParseCino('W'), virtcol('.')]
448-
if search('\m\S','W',num)
452+
if search('\m'.get(g:,'javascript_indent_W_pat','\S'),'W',num)
449453
return s:ParseCino('w') ? vcol : virtcol('.')-1
450454
endif
451455
return Wval ? s:Nat(num_ind + Wval) : vcol
@@ -455,7 +459,7 @@ function GetJavascriptIndent()
455459

456460
" main return
457461
if l:line =~ '^[])}]\|^|}'
458-
if l:line_raw[0] == ')'
462+
if l:line_s == ')'
459463
if s:ParseCino('M')
460464
return indent(l:lnum)
461465
elseif num && &cino =~# 'm' && !s:ParseCino('m')

0 commit comments

Comments
 (0)