fix(tables): don't split a cell on a | inside a link/code/escape
CI / editor tests (push) Successful in 46s

Table auto-alignment scanned for cell separators with a naive find('|'),
so a cell containing a vimwiki link `[[url|title]]` was split at the link's
internal pipe — mangling both the link (`[[url` / `title]]`) and the table
(a phantom extra column). Same bug in both the Lua (Neovim) and VimL (Vim)
table code, in both table_cell_starts and parse_table_row.

Add a shared cell-separator scanner (cell_bar_positions) that treats `|` as
literal — not a separator — when it's inside `[[…]]` wikilinks, `{{…}}`
transclusions, `` `…` `` inline code, or backslash-escaped (`\|`), matching
vimwiki. Both scan functions in each client now use it.

Regression tests added on both clients (cr.table_link_cell_pipe_not_a_separator);
full harness green (Neovim 308, Vim 302).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-02 11:56:59 +00:00
parent cd173f000c
commit 4c187fee3c
4 changed files with 90 additions and 31 deletions
+8
View File
@@ -336,6 +336,14 @@ call s:run('cr.adds_new_table_row', {
\ 'keys': "A\<CR>x\<Esc>",
\ 'expect_lines': ['| a | b |', '|x | |'],
\ })
" Regression: a `|` inside `[[u|t]]` must not split the cell — the link stays
" intact and the row keeps 2 columns (fresh row has 2 cells, not 3).
call s:run('cr.table_link_cell_pipe_not_a_separator', {
\ 'lines': ['| a | [[u|t]] |'],
\ 'cursor': [1, 4],
\ 'keys': "A\<CR>x\<Esc>",
\ 'expect_lines': ['| a | [[u|t]] |', '|x | |'],
\ })
" Insert <S-CR>: multiline list item — continue with NO marker, aligned under
" the text ("- " → 2 cols; "- [ ] " → 6 cols).
call s:run('cr.shift_cr_multiline', {
+10
View File
@@ -735,6 +735,16 @@ vim.defer_fn(function()
expect_lines = { '| a | b |', '|x | |' },
wait_ms = 100,
})
run('cr.table_link_cell_pipe_not_a_separator', {
-- Regression: the `|` inside `[[u|t]]` must NOT split the cell, so the
-- link stays intact and the row keeps its 2 columns (a 2-col fresh row,
-- not the mangled 3-col one the old naive `|` scan produced).
lines = { '| a | [[u|t]] |' },
cursor = { 1, 4 },
keys = 'A<CR>x<Esc>',
expect_lines = { '| a | [[u|t]] |', '|x | |' },
wait_ms = 100,
})
-- ===== Insert-mode table navigation (Cluster 6) =====