From d1871d619f6e837dcadebc77d2f5b4143a5d92ac Mon Sep 17 00:00:00 2001 From: Yansu Date: Thu, 12 Feb 2026 12:58:28 +0800 Subject: [PATCH] fix: prevent clipboard overwrite on single click without selection 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 #108 Co-Authored-By: Claude --- lib/selection-manager.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/selection-manager.ts b/lib/selection-manager.ts index d88c66d..0fdfa69 100644 --- a/lib/selection-manager.ts +++ b/lib/selection-manager.ts @@ -550,10 +550,12 @@ export class SelectionManager { this.isSelecting = false; this.stopAutoScroll(); - const text = this.getSelection(); - if (text) { - this.copyToClipboard(text); - this.selectionChangedEmitter.fire(); + if (this.hasSelection()) { + const text = this.getSelection(); + if (text) { + this.copyToClipboard(text); + this.selectionChangedEmitter.fire(); + } } } };