table alignment: break out of loop when separator found

This commit is contained in:
Steven Schmeiser 2018-07-09 10:05:30 -04:00
parent 7730fa28b5
commit 23d273d547
2 changed files with 11 additions and 9 deletions

View File

@ -237,7 +237,9 @@ endfunction "}}}
function! s:get_cell_aligns(lnum) "{{{ function! s:get_cell_aligns(lnum) "{{{
let aligns = {} let aligns = {}
for [lnum, row] in s:get_rows(a:lnum) for [lnum, row] in s:get_rows(a:lnum)
let found_separator = 0
if s:is_separator(row) if s:is_separator(row)
let found_separator = 1
let cells = vimwiki#tbl#get_cells(row) let cells = vimwiki#tbl#get_cells(row)
for idx in range(len(cells)) for idx in range(len(cells))
let cell = cells[idx] let cell = cells[idx]
@ -249,15 +251,15 @@ function! s:get_cell_aligns(lnum) "{{{
let aligns[idx] = 'left' let aligns[idx] = 'left'
endif endif
endfor endfor
else return aligns
endif
endfor
if !found_separator
let cells = vimwiki#tbl#get_cells(row) let cells = vimwiki#tbl#get_cells(row)
for idx in range(len(cells)) for idx in range(len(cells))
if !has_key(aligns, idx)
let aligns[idx] = 'left' let aligns[idx] = 'left'
endif
endfor endfor
endif endif
endfor
return aligns return aligns
endfunction "}}} endfunction "}}}

View File

@ -1658,8 +1658,8 @@ values: >
To indent table indent the first row. Then format it with 'gqq'. To indent table indent the first row. Then format it with 'gqq'.
You can specify horizontal alignment for columns in the separator. The You can specify the type of horizontal alignment for columns in the separator
default is left-align. > using the ':' character. The default is left-align. >
| Date | Item | Price | | Date | Item | Price |
|------------|:------:|--------:| |------------|:------:|--------:|