mirror of
https://github.com/junegunn/vim-easy-align.git
synced 2025-11-11 19:33:50 -05:00
Optimize recursive(*) alignment performance
This commit is contained in:
@@ -49,7 +49,7 @@ else
|
|||||||
endfunction
|
endfunction
|
||||||
endif
|
endif
|
||||||
|
|
||||||
function! s:do_align(just, fl, ll, fc, lc, pattern, nth, ml, mr, stick_to_left, recursive)
|
function! s:do_align(just, cl, fl, ll, fc, lc, pattern, nth, ml, mr, stick_to_left, recursive)
|
||||||
let lines = {}
|
let lines = {}
|
||||||
let max_just_len = 0
|
let max_just_len = 0
|
||||||
let max_delim_len = 0
|
let max_delim_len = 0
|
||||||
@@ -67,11 +67,14 @@ function! s:do_align(just, fl, ll, fc, lc, pattern, nth, ml, mr, stick_to_left,
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
if ignore_comment
|
if ignore_comment
|
||||||
execute "normal! ". line ."G^"
|
if !has_key(a:cl, line)
|
||||||
if synIDattr(synID(line, a:fc == 1 ? col('.') : a:fc, 0), 'name') =~? 'comment' &&
|
execute "normal! ". line ."G^"
|
||||||
\ synIDattr(synID(line, a:lc ? min([a:lc, col('$') - 1]) : (col('$') - 1), 0), 'name') =~? 'comment'
|
let a:cl[line] =
|
||||||
continue
|
\ synIDattr(synID(line, a:fc == 1 ? col('.') : a:fc, 0), 'name') =~? 'comment' &&
|
||||||
|
\ synIDattr(synID(line, a:lc ? min([a:lc, col('$') - 1]) : (col('$') - 1), 0), 'name') =~? 'comment'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if a:cl[line] | continue | endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Preserve indentation
|
" Preserve indentation
|
||||||
@@ -144,7 +147,7 @@ function! s:do_align(just, fl, ll, fc, lc, pattern, nth, ml, mr, stick_to_left,
|
|||||||
endfor
|
endfor
|
||||||
|
|
||||||
if a:recursive && a:nth < max_tokens
|
if a:recursive && a:nth < max_tokens
|
||||||
call s:do_align(a:just, a:fl, a:ll, a:fc, a:lc, a:pattern, a:nth + 1, a:ml, a:mr, a:stick_to_left, a:recursive)
|
call s:do_align(a:just, a:cl, a:fl, a:ll, a:fc, a:lc, a:pattern, a:nth + 1, a:ml, a:mr, a:stick_to_left, a:recursive)
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@@ -227,7 +230,7 @@ function! easy_align#align(just, ...) range
|
|||||||
|
|
||||||
if has_key(delimiters, ch)
|
if has_key(delimiters, ch)
|
||||||
let dict = delimiters[ch]
|
let dict = delimiters[ch]
|
||||||
call s:do_align(just, a:firstline, a:lastline,
|
call s:do_align(just, {}, a:firstline, a:lastline,
|
||||||
\ visualmode() == '' ? min([col("'<"), col("'>")]) : 1,
|
\ visualmode() == '' ? min([col("'<"), col("'>")]) : 1,
|
||||||
\ visualmode() == '' ? max([col("'<"), col("'>")]) : 0,
|
\ visualmode() == '' ? max([col("'<"), col("'>")]) : 0,
|
||||||
\ get(dict, 'pattern', ch),
|
\ get(dict, 'pattern', ch),
|
||||||
|
|||||||
Reference in New Issue
Block a user