commit 3c0ae2ff970ea9cf338e667297f3ddd4b87ac806
parent 4928132e5f65f535ffb6b048ca77b2ca226ba5dd
Author: Henry Qin <root@hq6.me>
Date: Wed, 3 Apr 2019 11:43:00 -0700
Revert "table alignment: break out of loop when separator found"
This reverts commit 23d273d54711035ac2b1c19838438521f0982595, which
fixes #655.
Description of fixed problem:
1. When looping through rows, if a separator was found, all subsequent
rows would not get an assigned alignment.
2. This breaks `s:get_aligned_rows` because it calls `s:fmt_sep` and
`s:fmt_row`, both of which expect `aligns` to have a value for every
row number.
Diffstat:
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/autoload/vimwiki/tbl.vim b/autoload/vimwiki/tbl.vim
@@ -278,8 +278,7 @@ endfunction
function! s:get_cell_aligns(lnum)
let aligns = {}
for [lnum, row] in s:get_rows(a:lnum)
- let found_separator = s:is_separator(row)
- if found_separator
+ if s:is_separator(row)
let cells = vimwiki#tbl#get_cells(row)
for idx in range(len(cells))
let cell = cells[idx]
@@ -291,15 +290,15 @@ function! s:get_cell_aligns(lnum)
let aligns[idx] = 'left'
endif
endfor
- return aligns
+ else
+ let cells = vimwiki#tbl#get_cells(row)
+ for idx in range(len(cells))
+ if !has_key(aligns, idx)
+ let aligns[idx] = 'left'
+ endif
+ endfor
endif
endfor
- if !found_separator
- let cells = vimwiki#tbl#get_cells(row)
- for idx in range(len(cells))
- let aligns[idx] = 'left'
- endfor
- endif
return aligns
endfunction