Skip to content

Fix: Allow triple-click selection in table cells by clamping to cell boundaries#6344

Merged
nathanlesage merged 2 commits into
Zettlr:developfrom
wyl2003:fix/Triple-click-in-a-table-cell
Jun 3, 2026
Merged

Fix: Allow triple-click selection in table cells by clamping to cell boundaries#6344
nathanlesage merged 2 commits into
Zettlr:developfrom
wyl2003:fix/Triple-click-in-a-table-cell

Conversation

@wyl2003

@wyl2003 wyl2003 commented May 18, 2026

Copy link
Copy Markdown
Contributor

Description

This PR fixes triple-click text selection inside table cells. Previously, a triple-click would attempt to select the entire line (which exceeds the cell's subview boundaries), causing the transaction to be outright disallowed — leaving the user unable to select all text in a cell with a triple-click.

The fix changes the boundary enforcement logic in ensureBoundariesFilter (in subview.ts) from disallowing out-of-bounds selection transactions to clamping them to the cell's boundaries instead. This allows triple-click select-all to work correctly within the cell.

Changes

source/common/modules/markdown-editor/table-editor/subview.ts

  • Replaced the blanket "disallow" behavior for out-of-bounds selections with clamping:
    if any selection range exceeds the cell boundaries, all ranges are clamped to the cell
    rather than the transaction being rejected.
  • The existing wasDeleted guard is preserved — transactions that would delete the cell
    itself are still disallowed.

No breaking changes to public APIs or UX beyond the intended fix.

Additional information

This fix was discussed in issue #6100.

A "check-then-clamp" strategy was chosen over "always-clamp" after benchmarking. The guard avoids allocating new EditorSelection objects on every transaction during normal editing (the common case), where selections are already within bounds.

AI Disclosure Statement

No AI was used in the development of this PR.

Tested on: Windows 11

@wanzy147

Copy link
Copy Markdown

I performed the operation locally: triple-click text selection inside table cells. The result showed that the selection was successfully confined to the table cell boundaries. The original bug has been successfully resolved, and thewasDeleted protection mechanism remains effective.

Tested on: macOS

@wyl2003 wyl2003 marked this pull request as ready for review May 19, 2026 12:39
@nathanlesage

Copy link
Copy Markdown
Member

Looks good, thank you!

@nathanlesage nathanlesage merged commit c5972ef into Zettlr:develop Jun 3, 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.

3 participants