-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Paste though mouse middle button does not insert text at cursor position #5065
Comments
How do you get middle mouse click to paste? |
Nothing special, it just works by default in my KDE environment. If I paste middle-clicking on the line where the cursor is, it works as expected. |
Got it. My guess is that middle click is the same as left click then paste? In that case fixing #4405 would probably resolve this as well (actually maybe not. I think the only way of "ignoring" the mouse click at this point is to detect the selection change, then reset the selection to where it was, but if the paste happens before we have the chance to do that, we'd be out of luck) |
The clipboard buffers are different with paste from the contextual menu (it pastes the Ctrl+C'ed selection, not the last selection). The position taken into account is where the right-click was done, but this time it moves the cursor. |
If the cursor is changing that means vscode is sending a selection change event which means it is probably the same as left click then paste. @jordanauge Can you confirm if the cursor moves in vscode even without this extension? If that is the case, from what I've been looking into selection changes I'm pretty sure you can't guarantee that you'll be able to reset the cursor before the paste. It might work most of the times (even though it will flicker the cursor), but if for some reason the extension host is busier it will probably not work. |
What I understood is that VScode seems to make a selection of what is between the current cursor position, and the position pointed by the mouse click (either middle or right click, and which explains why cursor disappears), and replaces it with the pasted text. When disabling the VIM extension this behaviour is pretty obvious, and the cursor moves after middle-click paste. What has confused me is that with the vim extension, the vim cursor is not moving at all in the case of a middle click paste (only moving when right-clicking), and this is confirmed by typing some text after the paste. Still, the paste has replaced the would-have-been-otherwise-selected text, consistently with the previous test. I hope this is more clear, summarized:
In VIM I am used to the click position not being taken into account during paste, which makes it easy to insert something at the cursor position. |
That's strange! I've just looked into vscode source and they are definitely changing the cursor to the click position when you middle click. So that should send us the selection change to move the cursor (now the paste could happen before or after this event), but after the paste we should get another selection change and again update the cursor. I don't have any linux machine right to now to test this. Could you try and build a version of this extension from PR #5050? I've included on that PR some debug information from selections. If you can do that and then set If you need any help on any of those steps just tell me. |
I tested with your branch and the behaviour is now coherent with the rest of VS code (the cursor now moves). Just fyi, i faced those little issues:
|
I think this issue should be open in vscode. With the current vscode API Idon't think we can make this work the way you want properly for the reasons stated above. What is the normal behavior of middle-click paste on other applications or other editors? Does it move the cursor? If it doesn't move the cursor then that is clearly a reason to open up an issue in vscode repo stating this as a bug. If it it moves the cursor even in other applications (except Vim like you mentioned) than you can always try to open a feature request issue in vscode asking them to at least make a configuration for that so that you enable or disable the cursor moving when you paste with middle button. |
I've tried to make this change and package vscode but for some reason I'm not able to package vscode. If you want you can try this branch I made with a possible fix for that on vscode. You will have to build and run vscode from that branch to test it. Check here to know how to do that. I'm not able to test it, but it should work. |
Thank you. I will try to dedicate some time to test this patch to vscode. While digging up, i noticed that the text being selected and thus replaced is me unnoticingly pressing SHIFT during paste as I tend to do in vim to altern between xtern and vim modes. Sorry for the confusion. On that point, the behaviour of vscode is pretty consistent, and it is better exploiting the shift modifier than others, say kate in the list hereafter. Still, the default behavour in vim seems not to mouse cursor in either mouse mode (if someone could confirm). Definitely this not a bug related to the vim plugin, and it should instead be a feature request to vscode, allowing the plugin to implement an option to emulate vim mouse management if chosen by the user. Not sure this should remain open in the meantime, or requalified as a feature request ? -- I'll log here my tests with the different editors: vim:
kate:
vscode (extensions disabled):
|
Reported before at microsoft/vscode#97387 |
Describe the bug
In addition to the text being incorrectly placed, sometimes other text also seems "randomly" deleted.
Although close to #4405, or other entries related to mouse/cursor interfaces, this one might deserve another entry.
To Reproduce
Expected behavior
In Vim (:set mouse=a), the paste occurs where the cursor is, not where the mouse clicked.
Environment :
Extension (VsCodeVim) version: v1.16.0
VSCode version: 1.47.2
OS: Debian/bullseye
The text was updated successfully, but these errors were encountered: