Skip to content

Commit 1cb6f10

Browse files
authored
cleaner loop (pangloss#765)
1 parent f33b9ed commit 1cb6f10

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

indent/javascript.vim

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,18 @@ endfunction
9595
" NOTE: Moves the cursor, unless a arg is supplied.
9696
function s:previous_token(...)
9797
let l:pos = getpos('.')[1:2]
98-
return [search('.\>\|[^[:alnum:][:space:]_$]','bW') ?
99-
\ (s:looking_at() == '/' || line('.') != l:pos[0] && getline('.') =~ '\/\/') &&
100-
\ s:syn_at(line('.'),col('.')) =~? s:syng_com ?
101-
\ search('\_[^/]\zs\/[/*]','bW') ? s:previous_token() : ''
102-
\ : s:token()
103-
\ : ''][a:0 && call('cursor',l:pos)]
98+
let token = ''
99+
while search('.\>\|[^[:alnum:][:space:]_$]','bW')
100+
if (s:looking_at() == '/' || line('.') != l:pos[0] && search('\/\/','nbW',
101+
\ line('.'))) && s:syn_at(line('.'),col('.')) =~? s:syng_com
102+
call search('\_[^/]\zs\/[/*]','bW')
103+
else
104+
let token = s:token()
105+
break
106+
endif
107+
endwhile
108+
call call('cursor', a:0 ? l:pos : [0,0])
109+
return token
104110
endfunction
105111

106112
" switch case label pattern

0 commit comments

Comments
 (0)