[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
This commit is contained in:
Konstantin Hudyakov
2026-08-14 15:57:11 +00:00
committed by intellij-monorepo-bot
parent 9ae7249ee2
commit 072bfd7aca
@@ -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()
}
}