Bug 475175 - Interactions between LSP Go to Definition and conventional Ctrl+Drag behavior
Summary: Interactions between LSP Go to Definition and conventional Ctrl+Drag behavior
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: general (show other bugs)
Version: 23.08.1
Platform: openSUSE Linux
: NOR minor
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-10-03 14:21 UTC by Grósz Dániel
Modified: 2023-10-04 15:45 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Grósz Dániel 2023-10-03 14:21:43 UTC
SUMMARY
The LSP feature of going to the definition on Control+Click interacts poorly with the pre-existing effects of Control+Drag:
- If you attempt to Control+Drag some selected text to copy it, and happen to have the mouse over an identifier when you start it, the editor goes to the definition, and then offers to drop the dragged text there (often in a different file).
- If you Control+Click an identifier without it being selected, and then slightly move the mouse after it goes to the definition, it selects the text between the target (at the center of the editor) and the mouse position, which is unintended and looks weird.

STEPS TO REPRODUCE
With selection:
1. Select some text, including an identifier.
2. Press Ctrl and the mouse button over the identifier.
3. Move the mouse and then release the button.

Without selection:
1. Press Ctrl and the mouse button over the identifier.
2. Move the mouse a little.

OBSERVED RESULT
With selection: goes to the definition (or declaration), and then copies the selected text there.

Without selection: goes to the definition, and then selects text between the location of the definition (typically vertically at the center of the editor) and the mouse cursor.

EXPECTED RESULT
With selection: drags and copies the selection, without going to the definition.

Without selection: Goes to the definition, and doesn't select text.

POSSIBLE SOLUTIONS
- Activate Go to Definition on mouse release, rather than mouse press, and then only if it hasn't been moved. (Perhaps a minor downside is that moving the mouse even slightly, within the identifier, disables Go to Definition.)
- Only activate Go to Definition on mouse release if the click is inside a selection, and then only if no drag is started. If the click isn't inside a selection, activate it on mouse press, but don't start a selection afterwards if the mouse is dragged.
- Always activate Go to Definition on mouse release, only if it's not dragging a selection, and if the mouse is still within the same identifier as when it was pressed. (If there was no selection, this is consistent with clicking a button.)

SOFTWARE/OS VERSIONS
Operating System: openSUSE Tumbleweed 20230929
KDE Plasma Version: 5.27.8
KDE Frameworks Version: 5.110.0
Qt Version: 5.15.10
Kernel Version: 6.4.11-1-default (64-bit)
Graphics Platform: X11
Comment 1 Waqar Ahmed 2023-10-03 14:46:55 UTC
Git commit 8f8b4d08c06ec4a9b537354622e505d0b3efce0e by Waqar Ahmed.
Committed on 03/10/2023 at 16:46.
Pushed by waqar into branch 'master'.

Dont handle ctrl-click if there is selection

M  +1    -1    addons/lspclient/lspclientpluginview.cpp

https://invent.kde.org/utilities/kate/-/commit/8f8b4d08c06ec4a9b537354622e505d0b3efce0e
Comment 2 Grósz Dániel 2023-10-04 15:16:56 UTC
Thanks for the quickest fix ever. But it may be an overkill to disable Ctrl+Click even when the click isn't in the selection, and the mouse isn't moved. Other editors seem to handle Ctrl+Click when the mouse is released, and ignore it if something is being dropped.
Comment 3 Waqar Ahmed 2023-10-04 15:34:18 UTC
> But it may be an overkill to disable Ctrl+Click even when the click isn't in the selection

Yes, I realized this today. So will modify it accordingly.

Not doing it on Mouse Release is different, there was some issue with it which I don't recall atm. Perhaps it will work now, will have to try.
Comment 4 Waqar Ahmed 2023-10-04 15:45:34 UTC
Git commit e3dcfde06b8ff5d20f5594f6cc142b6adb068027 by Waqar Ahmed.
Committed on 04/10/2023 at 17:38.
Pushed by waqar into branch 'master'.

Only avoid ctrl-click if click is in the selectionRange

M  +4    -2    addons/lspclient/lspclientpluginview.cpp

https://invent.kde.org/utilities/kate/-/commit/e3dcfde06b8ff5d20f5594f6cc142b6adb068027