Skip to content

Commit d377f45

Browse files
authored
regex simplified in trim() (pangloss#745)
1 parent d2bc5d4 commit d377f45

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

indent/javascript.vim

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ function s:previous_token()
7676
return search('.\>\|[][`^!"%-/:-?{-~]','bW') ?
7777
\ (s:looking_at() == '/' || line('.') != l:ln && getline('.') =~ '\/\/') &&
7878
\ synIDattr(synID(line('.'),col('.'),0),'name') =~? 'comment' ?
79-
\ search('\%(\/\@<!\/\/\|\/\*\)\&','bW') ? s:previous_token() : ''
79+
\ search('\_[^/]\zs\/[/*]','bW') ? s:previous_token() : ''
8080
\ : s:token()
8181
\ : ''
8282
endfunction
@@ -91,10 +91,10 @@ let s:continuation = get(g:,'javascript_continuation',
9191
" cursor at the last non-comment char.
9292
function s:Trim(ln,...)
9393
let pline = substitute(getline(a:ln),'\s*$','','')
94-
let l:max = max([match(pline,'.*\zs\%([^/]\zs\/\/\|\/\*\)'),0])
94+
let l:max = max([match(pline,'.*[^/]\zs\/[/*]'),0])
9595
while l:max && synIDattr(synID(a:ln, strlen(pline), 0), 'name') =~? 'comment\|doc'
9696
let pline = substitute(strpart(pline, 0, l:max),'\s*$','','')
97-
let l:max = max([match(pline,'.*\zs\%([^/]\zs\/\/\|\/\*\)'),0])
97+
let l:max = max([match(pline,'.*[^/]\zs\/[/*]'),0])
9898
endwhile
9999
return !a:0 || cursor(a:ln,strlen(pline)) ? pline : pline
100100
endfunction
@@ -137,7 +137,7 @@ endfunction
137137
function s:IsBlock()
138138
let l:ln = line('.')
139139
let char = s:previous_token()
140-
let syn = char =~ '[{>/]' || l:ln != line('.') ? synIDattr(synID(line('.'),col('.')-(char == '{'),0),'name') : ''
140+
let syn = char =~ '[{>/]' ? synIDattr(synID(line('.'),col('.')-(char == '{'),0),'name') : ''
141141
if syn =~? 'xml\|jsx'
142142
return char != '{'
143143
elseif char =~ '\k'

0 commit comments

Comments
 (0)