Skip to content

fix(tui): support copy mode over markdown tables#205

Merged
leohenon merged 2 commits into
leohenon:ocvfrom
shaheislam:table-copy
Jun 29, 2026
Merged

fix(tui): support copy mode over markdown tables#205
leohenon merged 2 commits into
leohenon:ocvfrom
shaheislam:table-copy

Conversation

@shaheislam

@shaheislam shaheislam commented Jun 29, 2026

Copy link
Copy Markdown

Problem

In copy mode, visual-line/char/block selection over markdown tables copied nothing or showed only a 1-character placeholder highlight. Tables render as TextTableRenderable, which exposes neither plainText nor lineInfo, so copy-mode's renderable walk skipped them.

Fix

  • Make copy-mode table-aware and extract per-display-line text from table cells.
  • Keep linewise table yanks as tab-separated cells without borders, matching the table's own selection format.
  • Skip table border rows for linewise yanks.
  • Use rendered table geometry for highlights, cursor movement, stick/preferred-column behavior, search, word motions, and char/block selection.

Before

Screenshot 2026-06-29 at 14 42 51

After

Screenshot 2026-06-29 at 14 41 25

Tests

  • Added copy-mode table regressions for TSV yank, border skipping, rendered highlight geometry, cursor movement, vertical preferred-column preservation, char visual yank, and wrapped cell lines.
  • bun test test/cli/tui/vim-motions.test.ts from packages/tui: 731 pass
  • bun typecheck from packages/tui: pass

@shaheislam

Copy link
Copy Markdown
Author

One for review when you get a moment :D @leohenon

const min = motionMin(row, cache)
return text.slice(Math.max(0, start.col - min), Math.max(0, end.col - min + 1))
}
return Array.from({ length: end.idx - start.idx + 1 }, (_, i) => ({ row: list[start.idx + i], i: start.idx + i }))

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed charwise table selections include non copyable separator rows as blank lines. Can we filter rowCopyable(row, cache) here, and in the block visual path above, matching the linewise behavior?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done thanks @leohenon

- skip non-copyable table rows in visual copy
@leohenon

Copy link
Copy Markdown
Owner

I just added a comment for the table internals, and a columnOffsets guard in the table adapter. Thanks for tackling this, its a solid improvement.

@leohenon leohenon merged commit b5f4bd1 into leohenon:ocv Jun 29, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants