Skip to content

Commit 3ea6ed6

Browse files
authored
Trim optimize (pangloss#1024)
1 parent c03aee7 commit 3ea6ed6

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

indent/javascript.vim

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -241,14 +241,11 @@ function s:Continues(ln,con)
241241
endfunction
242242

243243
function s:Trim(ln)
244-
let pline = substitute(getline(a:ln),'\s*$','','')
245-
let l:max = max([strridx(pline,'//'), strridx(pline,'/*')])
246-
while l:max != -1 && s:SynAt(a:ln, strlen(pline)) =~? s:syng_com
247-
let pline = pline[: l:max]
248-
let l:max = max([strridx(pline,'//'), strridx(pline,'/*')])
249-
let pline = substitute(pline[:-2],'\s*$','','')
244+
let divi = split(getline(a:ln),'\s\+$\|\S\zs\ze\s*\/[/*]')
245+
while len(divi) > 1 && s:SynAt(a:ln, strlen(join(divi,''))) =~? s:syng_com
246+
call remove(divi,-1)
250247
endwhile
251-
return pline
248+
return join(divi,'')
252249
endfunction
253250

254251
" Find line above 'lnum' that isn't empty or in a comment

0 commit comments

Comments
 (0)