Skip to content

Commit 1bd80e0

Browse files
authored
edge case fix: prevcodeline() and c style comments (pangloss#994)
1 parent 72f4a95 commit 1bd80e0

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

indent/javascript.vim

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,15 +252,28 @@ function s:PrevCodeLine(lnum)
252252
let l:n = prevnonblank(a:lnum)
253253
while l:n
254254
if getline(l:n) =~ '^\s*\/[/*]'
255-
if (stridx(getline(l:n),'`') != -1 || getline(l:n-1)[-1:] == '\') &&
255+
if (getline(l:n) =~ '`' || getline(l:n-1)[-1:] == '\') &&
256256
\ s:SynAt(l:n,1) =~? b:syng_str
257257
break
258258
endif
259259
let l:n = prevnonblank(l:n-1)
260-
elseif stridx(getline(l:n), '*/') != -1 && s:SynAt(l:n,1) =~? s:syng_com
260+
elseif getline(l:n) =~ '\*\/' && s:SynAt(l:n,1) =~? s:syng_com
261261
let l:pos = getpos('.')
262262
call cursor(l:n,1)
263-
let l:n = search('\/\*','nbW')
263+
let l:n = search('\/\*','bW')
264+
while search('\/\*\|\(\*\/\)','bWp') == 1
265+
let br = 0
266+
for l:i in range(l:n,line('.'),-1)
267+
if s:SynAt(l:i,l:i == line('.') ? col('.') : 1) !~? s:syng_com
268+
let br = 1
269+
break
270+
endif
271+
endfor
272+
if br
273+
break
274+
endif
275+
let l:n = line('.')
276+
endwhile
264277
call setpos('.',l:pos)
265278
else
266279
break

0 commit comments

Comments
 (0)