From 072bfd7acaa91a3df48d6fa3b5b350a3fa821652 Mon Sep 17 00:00:00 2001 From: Konstantin Hudyakov Date: Mon, 10 Aug 2026 10:07:21 +0300 Subject: [PATCH] [terminal] IJPL-251692 Fix double selection in Claude Code fullscreen mode Current priority of the mouse events handling is the following: hyperlinks -> TerminalMouseEventsHandlerImpl (mouse reporting) -> editor (text selection). So, to protect from selecting text both by the editor and by the running application, we need to consume mouse events reported to the process. It corresponds to how other terminals do: if mouse reporting is enabled, they send all events to the process and do not handle them on the terminal side. In our case we only handle hyperlinks before mouse reporting to make them work in this mode. (cherry picked from commit 92a20c0ee96baeb095c39f8eabb64356d627f6b6) IJ-CR-218081 GitOrigin-RevId: 3e537e550db41d71cea52880295131162932cb15 --- .../impl/TerminalMouseEventsHandlerImpl.kt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/plugins/terminal/frontend/src/com/intellij/terminal/frontend/view/impl/TerminalMouseEventsHandlerImpl.kt b/plugins/terminal/frontend/src/com/intellij/terminal/frontend/view/impl/TerminalMouseEventsHandlerImpl.kt index 538fa4d28df5..2af5bf9c08bb 100644 --- a/plugins/terminal/frontend/src/com/intellij/terminal/frontend/view/impl/TerminalMouseEventsHandlerImpl.kt +++ b/plugins/terminal/frontend/src/com/intellij/terminal/frontend/view/impl/TerminalMouseEventsHandlerImpl.kt @@ -46,6 +46,10 @@ internal class TerminalMouseEventsHandlerImpl( } code = applyModifierKeys(event, code) terminalInput.sendBytes(mouseReport(code, x + 1, y + 1)) + + // Consume the mouse event to avoid double processing: + // by the terminal process and the editor logic (for example, text selection). + event.consume() } } } @@ -68,6 +72,10 @@ internal class TerminalMouseEventsHandlerImpl( } code = applyModifierKeys(event, code) terminalInput.sendBytes(mouseReport(code, x + 1, y + 1)) + + // Consume the mouse event to avoid double processing: + // by the terminal process and the editor logic (for example, text selection). + event.consume() } } lastMotionReport = null @@ -85,6 +93,10 @@ internal class TerminalMouseEventsHandlerImpl( terminalInput.sendBytes( mouseReport(MouseButtonCodes.RELEASE or MouseButtonModifierFlags.MOUSE_BUTTON_MOTION_FLAG, x + 1, y + 1) ) + + // Consume the mouse event to avoid double processing: + // by the terminal process and the editor logic (for example, text selection). + event.consume() } lastMotionReport = Point(x, y) } @@ -104,6 +116,10 @@ internal class TerminalMouseEventsHandlerImpl( code = code or MouseButtonModifierFlags.MOUSE_BUTTON_MOTION_FLAG code = applyModifierKeys(event, code) terminalInput.sendBytes(mouseReport(code, x + 1, y + 1)) + + // Consume the mouse event to avoid double processing: + // by the terminal process and the editor logic (for example, text selection). + event.consume() } } lastMotionReport = Point(x, y) @@ -132,6 +148,9 @@ internal class TerminalMouseEventsHandlerImpl( repeat(abs(event.unitsToScroll)) { terminalInput.sendBytes(arrowKeys) } + + // Consume the mouse event to avoid double processing: + // by the terminal process and the editor logic (for example, text selection). event.consume() } }