fix: prevent clipboard overwrite on single click without selection#124
Open
zerone0x wants to merge 1 commit intocoder:mainfrom
Open
fix: prevent clipboard overwrite on single click without selection#124zerone0x wants to merge 1 commit intocoder:mainfrom
zerone0x wants to merge 1 commit intocoder:mainfrom
Conversation
The mouseup handler in SelectionManager was calling copyToClipboard() without first checking hasSelection(), causing single clicks on terminal cells to copy the character at that position to the clipboard. This overwrote the user's clipboard contents unexpectedly. Added a hasSelection() guard in the mouseup handler to match the pattern already used in the public copySelection() API. Fixes coder#108 Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #108
Single clicks on terminal cells were triggering
copyToClipboard()in themouseuphandler without checkinghasSelection()first. This caused the user's clipboard to be silently overwritten with a single character from the clicked cell, even when no text was selected.Changes
hasSelection()guard in themouseuphandler inSelectionManager, matching the existing pattern in the publiccopySelection()APIRoot Cause
The
mousedownhandler sets bothselectionStartandselectionEndto the same cell on click, andisSelecting = true. Whenmouseupfires (without any drag),getSelection()returns the character at that single cell, andcopyToClipboard()overwrites the clipboard. ThehasSelection()method correctly identifies same-cell selections as not real selections, but themouseuphandler wasn't calling it.Test Plan
🤖 Generated with Claude Code (issue-hunter-pro)