fix(tables): don't split a cell on a | inside a link/code/escape
CI / editor tests (push) Successful in 46s
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:
@@ -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) =====
|
||||
|
||||
|
||||
Reference in New Issue
Block a user