Skip to content

Fix double-click text selection - #4801

Open
dgageot wants to merge 1 commit into
docker:mainfrom
dgageot:worktree-board-37aff6d6f7d76be5
Open

dgageot wants to merge 1 commit into
docker:mainfrom
dgageot:worktree-board-37aff6d6f7d76be5

Conversation

@dgageot

@dgageot dgageot commented Nov 3, 2026

Copy link
Copy Markdown
Member

Summary

  • Preserve table border coordinates for accurate double-click word selection.
  • Use Unicode word boundaries and grapheme-aware hit testing, highlighting, and clipboard extraction; preserve auto-copy after dragging away and back.
  • Cover rendered Markdown, Unicode and graphemes, and empty selections with tests.

Validation

  • task dev (build, full tests, and lint) passed.

Assisted-By: Docker Agent
@dgageot
dgageot requested a review from a team as a code owner November 3, 2026 20:38
Copilot AI balanced review requested due to automatic review settings November 3, 2026 20:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Highlighting still slices at raw mouse columns, so partial-width selections of wide graphemes can display spaces while copying the full glyph; highlight bounds need to match the clipboard’s grapheme boundaries.

1 open issue
What changed in this PR

This PR improves text selection in the message TUI by preserving rendered table coordinates and handling Unicode graphemes consistently during word selection and clipboard extraction.

Changes:

  • Preserve table borders during hit testing and use Unicode-aware word classification.
  • Add grapheme-based clipboard extraction and update display-width calculations.
  • Preserve auto-copy after multi-click drags return to their starting point, with regression tests.
File Description
pkg/​tui/​components/​messages/​selection.go Updates word selection, width calculations, and drag state.
pkg/​tui/​components/​messages/​selection_test.go Tests Markdown, Unicode, highlighting, and drag behavior.
pkg/​tui/​components/​messages/​messages.go Tracks movement to preserve copy-on-release behavior.
pkg/​tui/​components/​messages/​lineutil.go Adds grapheme-to-column mapping and updates styling width calculations.
pkg/​tui/​components/​messages/​clipboard.go Extracts whole intersecting graphemes and rejects empty selections.
pkg/​tui/​components/​messages/​clipboard_test.go Tests clipboard extraction across grapheme and border boundaries.

Review effort: Balanced

func styleLineSegment(line string, startCol, endCol int, style lipgloss.Style) string {
plainLine := ansi.Strip(line)
plainWidth := runewidth.StringWidth(plainLine)
plainWidth := ansi.StringWidth(line)
@aheritier aheritier added area/tui For features/issues/fixes related to the TUI kind/fix PR fixes a bug (maps to fix:). Use on PRs only. labels Nov 3, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/tui For features/issues/fixes related to the TUI kind/fix PR fixes a bug (maps to fix:). Use on PRs only.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants