Skip to content

Commit 187b1d6

Browse files
authored
recursion in isBlock: comment skip (#692)
1 parent afb03f5 commit 187b1d6

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

indent/javascript.vim

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -115,21 +115,15 @@ function s:iscontOne(i,num,cont)
115115
endfunction
116116

117117
" https://github.com/sweet-js/sweet.js/wiki/design#give-lookbehind-to-the-reader
118-
function s:IsBlock()
119-
let l:ln = line('.')
118+
function s:IsBlock(...)
119+
let l:ln = get(a:000,0,line('.'))
120120
if search('\S','bW')
121121
let char = getline('.')[col('.')-1]
122122
let pchar = getline('.')[col('.')-2]
123123
let syn = synIDattr(synID(line('.'),col('.')-1,0),'name')
124-
if pchar . char == '*/' && syn =~? 'comment'
125-
if !search('\/\*','bW') || !search('\S','bW')
126-
return 1
127-
endif
128-
let char = getline('.')[col('.')-1]
129-
let pchar = getline('.')[col('.')-2]
130-
let syn = synIDattr(synID(line('.'),col('.')-1,0),'name')
131-
endif
132-
if syn =~? '\%(xml\|jsx\)'
124+
if syn =~? 'comment'
125+
return search('\/[/*]','bW') && s:IsBlock(l:ln)
126+
elseif syn =~? '\%(xml\|jsx\)'
133127
return char != '{'
134128
elseif char =~# '\l'
135129
return index(split('return const let import export yield default delete var void typeof throw new in instanceof')

0 commit comments

Comments
 (0)