From 560b322ea0d629e864c7e09ef9f8a573cd6e6d49 Mon Sep 17 00:00:00 2001 From: Sergey Simonchik Date: Mon, 13 Oct 2025 14:08:12 +0200 Subject: [PATCH] [terminal] IJPL-212018 do not send `SCROLLUP` mouse event for scroll events with `wheelRotation = 0` This fixes for 'Reworked 2025' terminal. For 'Classic' terminal, it was fixed by https://jetbrains.team/p/ij/repositories/jediterm/revision/fb0f77c7ea2b611c2d666afe8d2821a7fe5a6140 GitOrigin-RevId: 5d12b683cf815ace8263079edd3e09b1c3193914 --- .../view/impl/TerminalEventsHandlerImpl.kt | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/plugins/terminal/frontend/src/com/intellij/terminal/frontend/view/impl/TerminalEventsHandlerImpl.kt b/plugins/terminal/frontend/src/com/intellij/terminal/frontend/view/impl/TerminalEventsHandlerImpl.kt index 2f5d38bffd0a..e1db1b96ef33 100644 --- a/plugins/terminal/frontend/src/com/intellij/terminal/frontend/view/impl/TerminalEventsHandlerImpl.kt +++ b/plugins/terminal/frontend/src/com/intellij/terminal/frontend/view/impl/TerminalEventsHandlerImpl.kt @@ -313,13 +313,21 @@ internal open class TerminalEventsHandlerImpl( return when { SwingUtilities.isLeftMouseButton(event) -> MouseButtonCodes.LEFT SwingUtilities.isMiddleMouseButton(event) -> MouseButtonCodes.MIDDLE - SwingUtilities.isRightMouseButton( - event) -> MouseButtonCodes.NONE //we don't handle right mouse button as it used for the context menu invocation - event is MouseWheelEvent -> if (event.wheelRotation > 0) MouseButtonCodes.SCROLLUP else MouseButtonCodes.SCROLLDOWN + SwingUtilities.isRightMouseButton(event) -> { + // we don't handle the right mouse button as it used for the context menu invocation + MouseButtonCodes.NONE + } + event is MouseWheelEvent -> wheelRotationToButtonCode(event.wheelRotation) else -> return MouseButtonCodes.NONE } } + private fun wheelRotationToButtonCode(wheelRotation: Int): Int = when { + wheelRotation > 0 -> MouseButtonCodes.SCROLLUP + wheelRotation < 0 -> MouseButtonCodes.SCROLLDOWN + else -> MouseButtonCodes.NONE + } + private fun applyModifierKeys(event: MouseEvent, cb: Int): Int { var code = cb if (event.isControlDown) {