small fix in s:get_aligned_rows()

This commit is contained in:
Alexey Radkov 2014-05-04 18:42:00 +04:00
parent cd25233cc8
commit 4d1bb91dbe

View File

@ -263,6 +263,7 @@ function! s:get_aligned_rows(lnum, col1, col2) "{{{
let cells = [] let cells = []
let max_lens = {} let max_lens = {}
let lrows = len(rows) let lrows = len(rows)
let check_all = 1
if lrows == depth + 1 if lrows == depth + 1
let i = 1 let i = 1
for [lnum, row] in rows for [lnum, row] in rows
@ -271,16 +272,17 @@ function! s:get_aligned_rows(lnum, col1, col2) "{{{
endfor endfor
let max_lens = s:get_cell_max_lens(a:lnum, cells, startlnum, rows) let max_lens = s:get_cell_max_lens(a:lnum, cells, startlnum, rows)
let fst_lens = s:get_cell_max_lens(a:lnum, cells, startlnum, rows[0:0]) let fst_lens = s:get_cell_max_lens(a:lnum, cells, startlnum, rows[0:0])
if max_lens != fst_lens let check_all = max_lens != fst_lens
" all the table must be re-formatted endif
let rows = s:get_rows(a:lnum) if check_all
let startlnum = rows[0][0] " all the table must be re-formatted
let cells = [] let rows = s:get_rows(a:lnum)
for [lnum, row] in rows let startlnum = rows[0][0]
call add(cells, vimwiki#tbl#get_cells(row)) let cells = []
endfor for [lnum, row] in rows
let max_lens = s:get_cell_max_lens(a:lnum, cells, startlnum, rows) call add(cells, vimwiki#tbl#get_cells(row))
endif endfor
let max_lens = s:get_cell_max_lens(a:lnum, cells, startlnum, rows)
endif endif
let result = [] let result = []
for [lnum, row] in rows for [lnum, row] in rows