Skip to content

simplify trimline #673

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Oct 18, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 7 additions & 16 deletions indent/javascript.vim
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,14 @@ else
endfunction
endif

" indent/python.vim
function s:Trimline(ln)
let pline = getline(a:ln)
let min = match(pline,'\/[/*]') + 1
if min && synIDattr(synID(a:ln, strlen(pline), 0), 'name') =~? '\%(comment\|doc\)'
let max = match(pline,'.*\zs\/[/*]') + 1
while min < max
let col = (min + max) / 2
if synIDattr(synID(a:ln, col, 0), 'name') =~? '\%(comment\|doc\)'
let max = col
else
let min = match(pline,'\/[/*]',col) + 1
endif
endwhile
let pline = strpart(pline, 0, min - 1)
endif
return substitute(pline,'\s*$','','')
let pline = substitute(getline(a:ln),'\s*$','','')
let max = max([strridx(pline,'//'),strridx(pline,'/*'),0])
while max && synIDattr(synID(a:ln, strlen(pline), 0), 'name') =~? '\%(comment\|doc\)'
let pline = substitute(strpart(pline, 0, max),'\s*$','','')
let max = max([strridx(pline,'//'),strridx(pline,'/*'),0])
endwhile
return pline
endfunction

" configurable regexes that define continuation lines, not including (, {, or [.
Expand Down