commit 1f77b7e6f65dbb99a080bb0c32a8b1691fdcc48b
parent 84e9422c7c6a6edb82829c5b7c739a9398f717fd
Author: Tinmarino <tinmarino@gmail.com>
Date: Mon, 17 May 2021 10:27:59 -0400
Table: Fix exception if i<Tab> at end of line if next line is bad (Issue #1126)
Diffstat:
2 files changed, 29 insertions(+), 7 deletions(-)
diff --git a/autoload/vimwiki/tbl.vim b/autoload/vimwiki/tbl.vim
@@ -224,12 +224,12 @@ endfunction
function! s:get_rows(lnum, ...) abort
+ let rows = []
+
if !s:is_table(getline(a:lnum))
- return
+ return rows
endif
- let rows = []
-
let lnum = a:lnum - 1
let depth = a:0 > 0 ? a:1 : 0
let ldepth = 0
@@ -357,7 +357,7 @@ function! s:get_aligned_rows(lnum, col1, col2, depth) abort
let check_all = 1
if a:depth > 0
let rows = s:get_rows(a:lnum, a:depth)
- let startlnum = rows[0][0]
+ let startlnum = len(rows) > 0 ? rows[0][0] : 0
let lrows = len(rows)
if lrows == a:depth + 1
let line = rows[-1][1]
@@ -388,7 +388,7 @@ function! s:get_aligned_rows(lnum, col1, col2, depth) abort
if check_all
" all the table must be re-formatted
let rows = s:get_rows(a:lnum)
- let startlnum = rows[0][0]
+ let startlnum = len(rows) > 0 ? rows[0][0] : 0
let cells = []
for [lnum, row] in rows
call add(cells, vimwiki#tbl#get_cells(row))
@@ -548,7 +548,7 @@ function! vimwiki#tbl#goto_next_col() abort
let depth = 2
let newcol = s:get_indent(lnum, depth)
let rows = s:get_rows(lnum, depth)
- let startlnum = rows[0][0]
+ let startlnum = len(rows) > 0 ? rows[0][0] : 0
let cells = []
for [lnum, row] in rows
call add(cells, vimwiki#tbl#get_cells(row, 1))
@@ -583,7 +583,7 @@ function! vimwiki#tbl#goto_prev_col() abort
let depth = 2
let newcol = s:get_indent(lnum, depth)
let rows = s:get_rows(lnum, depth)
- let startlnum = rows[0][0]
+ let startlnum = len(rows) > 0 ? rows[0][0] : 0
let cells = []
for [lnum, row] in rows
call add(cells, vimwiki#tbl#get_cells(row, 1))
diff --git a/test/table.vader b/test/table.vader
@@ -1,6 +1,28 @@
# Table autoformating
# Very configurable: read doc/design_notes.md
+# Move <Tab> at end of row if next row is badly formated {{{1
+# See #1126
+##########################
+Given vimwiki (Header ok but 1 row bad):
+ | Service to be Build | Build Tag | Service to Deploy | Deploy Tag | Comments |
+ |---------------------|-----------|-------------------|------------|----------|
+ |||Provision/Core/Keycloak|release-3.8.0_RC9|This was done as part of release-3.7.0 hotfix and is not required if you are already on Keycloak 7|
+ |||Provision/DataPipeline/AnalyticsSpark|release-3.8.0_RC6||
+ |||OpsAdministration/Core/ESMapping|release-3.8.0_RC9|Choose `userv1,orgv2` for jenkins job parameter `indices_name`|
+
+Do (i<tab> at end of first line):
+ $i\<Tab>
+
+Expect(Crash (List required)):
+# E714: List required <= tbl#goto_next_col, line 9
+ | Service to be Build | Build Tag | Service to Deploy | Deploy Tag | Comments |
+ |---------------------|-----------|-------------------|------------|----------|
+ |||Provision/Core/Keycloak|release-3.8.0_RC9|This was done as part of release-3.7.0 hotfix and is not required if you are already on Keycloak 7|
+ |||Provision/DataPipeline/AnalyticsSpark|release-3.8.0_RC6||
+ |||OpsAdministration/Core/ESMapping|release-3.8.0_RC9|Choose `userv1,orgv2` for jenkins job parameter `indices_name`|
+
+
# Move <Tab> and <S-Tab> map {{{1
# See #1048
##########################