fix(tables): cycle Tab into the next row instead of inserting one
Pressing <Tab> past the last cell unconditionally appended a new row below, even when there was already a next row to jump into. Tabbing through a header → separator → body table from the header row inserted a blank row between header and separator instead of landing in the first body cell. After the final cell, walk forward from the current row to the end of the table, skip any separator row, and jump to the first cell of the next data row. Only insert a fresh row when the cursor is on the table's last row (or only separator rows follow). Applied to both the Vim (autoload/nuwiki/commands.vim) and Neovim (lua/nuwiki/ commands.lua) sides so the two harnesses stay in sync; covered by new keymap tests in scripts/test-keymaps-vim.vim and test-keymaps.lua. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -454,6 +454,21 @@ vim.defer_fn(function()
|
||||
expect_lines = { '| a |x b |' },
|
||||
wait_ms = 100,
|
||||
})
|
||||
run('tab.cycles_to_next_row_when_not_last', {
|
||||
lines = { '| a | b |', '|---|---|', '| c | d |' },
|
||||
cursor = { 1, 6 }, -- inside last cell of header row
|
||||
keys = 'i<Tab>x<Esc>',
|
||||
-- Past the final cell of row 1: skip separator, land in first cell of row 3.
|
||||
expect_lines = { '| a | b |', '|---|---|', '|x c | d |' },
|
||||
wait_ms = 100,
|
||||
})
|
||||
run('tab.inserts_row_only_when_on_last_row', {
|
||||
lines = { '| a | b |', '|---|---|', '| c | d |' },
|
||||
cursor = { 3, 6 }, -- inside last cell of last data row
|
||||
keys = 'i<Tab>x<Esc>',
|
||||
expect_lines = { '| a | b |', '|---|---|', '| c | d |', '|x | |' },
|
||||
wait_ms = 100,
|
||||
})
|
||||
run('shift_tab.prev_cell_in_table', {
|
||||
lines = { '| a | b |' },
|
||||
cursor = { 1, 6 }, -- inside cell `b`
|
||||
|
||||
Reference in New Issue
Block a user