Skip to content

Fix/mouse coordinate selection#1209

Closed
pepperpepperpepper wants to merge 6 commits into
anomalyco:devfrom
pepperpepperpepper:fix/mouse-coordinate-selection
Closed

Fix/mouse coordinate selection#1209
pepperpepperpepper wants to merge 6 commits into
anomalyco:devfrom
pepperpepperpepper:fix/mouse-coordinate-selection

Conversation

@pepperpepperpepper
Copy link
Copy Markdown

These changes make mouse text selection in the TUI chat work as expected -
like other terminal applications. Users can now select text beyond the viewport with automatic
scrolling, and clipboard behavior follows standard Ctrl+C patterns instead of immediate copy on
release.

Pepper added 3 commits July 21, 2025 23:22
- Fix mouse Y coordinate mapping by accounting for header height
- Add proper offset calculation for viewport-relative coordinates
- Enable auto-scroll during text selection near viewport edges
- Remove automatic clipboard copying on mouse release

The mouse coordinates were previously calculated relative to the terminal
window, but needed to be adjusted for the header height and viewport
positioning. This ensures accurate text selection and smooth scrolling
behavior during selection operations.
- Fixed double offset application causing 7-8 line selection offset
- Mouse coordinates now correctly map to text under cursor
- Selection rendering uses content-relative coordinates
- Preserves auto-scroll functionality during text selection
- Fix mouse coordinate mapping for accurate text selection
- Add auto-scroll functionality when selecting near viewport edges
- Fix Unicode character width calculation for proper selection
- Disable tail mode during selection to allow free scrolling
- Remove automatic clipboard copying on mouse release
@benemorius
Copy link
Copy Markdown

Thank you! This solves the text-selection problem for me. Without this PR, trying to select text actually writes text all over the screen. After this PR, I can select text normally without disturbing it.

However, this PR has broken my ability to scroll down after scrolling up. Steps to reproduce: start opencode; resume a session with enough history to require scrolling; scroll up, then try scrolling back down. Only the bottom 5% of the window scrolls back down. Although I didn't actually use opencode yet before applying this PR, I can't seem to reproduce this scroll bug without this PR so I think it's new behavior.

@pepperpepperpepper
Copy link
Copy Markdown
Author

@benemorius I can't reproduce your error. Are you certain you can't scroll back down?

Pepper added 2 commits July 22, 2025 17:25
- Added right-click functionality to copy selected text to clipboard
- Removed revert/redo commands that were causing build issues
- Maintained existing left-click selection behavior
- Clean implementation based on dev branch mouse selection logic
@pepperpepperpepper
Copy link
Copy Markdown
Author

added right click copy into pastebuffer

@pepperpepperpepper
Copy link
Copy Markdown
Author

If you're interested in using this pr or patching opencode, just lmk I've merged it into my own working branch "unchained" which has this and some other performance enhancements. Thanks

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 2, 2026

Closing this pull request because it has had no updates for more than 60 days. If you plan to continue working on it, feel free to reopen or open a new PR.

@github-actions github-actions Bot closed this Feb 2, 2026
@CarloWood
Copy link
Copy Markdown
Contributor

Stuff like this makes me run away as far as I can from getting involved with this project.

Someone writes a good fix that is obviously needed; it gets ignored.

They keep merging and fixing collisions with the dev branch, but nothing is merged.

After a while they give up and stop putting time into fixing the never-ending-collisions.
Two months later a bot closes this PR because "no updates for 60 days"... Seriously?

What is opencode expecting if they don't address PR's?

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