VSCodeVim / Vim

:star: Vim for Visual Studio Code
http://aka.ms/vscodevim
MIT License
14.02k stars 1.32k forks source link

Disable cursor positioning with mouse in normal mode #4405

Open nicholascannon opened 4 years ago

nicholascannon commented 4 years ago

Is your feature request related to a problem? Please describe. Whenever I want to focus my editor I use the mouse and randomly click inside it. Doing this repositions the cursor. I'd rather it just reactivate the editor and keep the cursor at the line it was at before and then use vim commands to navigate the file. Basically the same behaviour when using the mouse with vim in terminal.

Describe the solution you'd like Mouse clicks inside the editor (whilst in normal) mode does not change the cursor location.

Describe alternatives you've considered Using the keyboard shortcut to focus the editor. Not really a fan of the shortcut and I frequently use the mouse when navigating the file explorer within vscode.

Additional context Selecting text should still work. If you're having trouble understanding the behaviour i'm describing open your terminal and run vim on a text file and use the mouse inside.

J-Fields commented 4 years ago

Selecting text should still work

Not sure this is really possible with the current VSCode API. The closest we could get, I think, would be using a second cursor for the selection, but then we'd need to ignore this cursor and its selection for most commands and try to counter-act VSCode's operations on it. Frankly, I'm not sure the result would be very satisfying and would add significant complexity to the code base.

nicholascannon commented 4 years ago

@J-Fields Selecting Selecting text with the mouse isn't really a big deal (not worth it if it will add a lot of complexity with not very good results) as I (and I assume most others) will use visual modes to select text. Mainly the cursor repositioning is important, hopefully this can be done without adding too much complexity to the code base.

Dieterbe commented 4 years ago

+1 coming from vim, this is very frustrating. So often in vim I have a cursor where i want to paste, press 'i' for insert mode, copy some text somewhere with my mouse, then press 'p' to paste.

But because of this issue that workflow pattern breaks :(

jjthiessen commented 4 years ago

Similarly, but different, I don't mind my cursor moving about while in normal mode, but it's really annoying for me when mouse events reposition the cursor while I'm in insert mode. This is because I use primary selection a lot. When middle-click pasting, I don't want to have to click in the exact right place to make it work (the cursor warps before pasting occurs). I don't have the same issue with focusing and raising windows (because focus follows mouse, and I'm using a tiling WM), but I understand you'd have the same problem otherwise (if you use click to focus and you left your editor in insert mode while changing windows).

Adolf-L commented 4 years ago

Disable cursor positioning with mouse in normal mode which is a important UX.... we need this feature.

Pivert commented 4 years ago

This behaviour is very frustrating, being obliged to super carefully middle click on the line you activated the insert (vim mode) to properly paste. For the left mouse click, I can cope with it. But for the middle (paste) click, this really breaks the workflow.

ragvri commented 4 years ago

I am facing the opposite issue. I don't know why but my cursor position does not update when I click at some other location in normal mode. When I go back to insert mode, the cursor goes back to where it was before click. I do not want this

junekhan commented 4 years ago

I am facing the opposite issue. I don't know why but my cursor position does not update when I click at some other location in normal mode. When I go back to insert mode, the cursor goes back to where it was before click. I do not want this

Same here. About one week ago before I updated my VSCode and its plugins, everything was fine, the cursor followed my mouse and keyboard consecutively, I've been long used to it. So please, provide us with the option to choose our preferences.

apolzon commented 4 years ago

Just chiming in that having the cursor "lie" about its current location after mouse-clicking is incredibly unintuitive. This behavior changed sometime in the last couple weeks as it was working as expectedly before.

What is really weird is that some movement commands will move the cursor in its current location instead of reverting to the previous location -- horizontal movements (hjwb etc) use the previous location, but if you click and then use vertical movement (jk), the cursor will behave as expected, and update its "real" location so that you can then use horizontal movement.

I would guess my explanation is not very clear, if a video is needed to better illustrate what is happening please let us know.

pwnz22 commented 4 years ago

I am facing the opposite issue. I don't know why but my cursor position does not update when I click at some other location in normal mode. When I go back to insert mode, the cursor goes back to where it was before click. I do not want this

Also facing this issue. Is there any option how to revert this!?

SergeiStruk commented 4 years ago

Also facing this issue. Is there any option how to revert this!?

As a temporary solution downgrade to 1.16.0 helped me: https://www.vsixhub.com/vsix/38553/. You can install it using this command: code --install-extension vim-1.16.0_vsixhub.com.vsix. Also I disabled extensions auto updating.

salolivares commented 4 years ago

An alternative is to downgrade VSVim in VSCode itself: Extensions -> Vim -> Settings -> Install Another Version 1

xuchen commented 4 years ago

the opposite happened to me in version 1.17.0 released 2 days ago (9/23/2020), which also broke my normal usage pattern. Downgrading to 1.16.0 solved the problem, I have vim cursor following mouse back.

To summarize, I think 1.16.0 has roughly (vim cursor follows mouse):

set mouse=a     " Enable mouse usage (all modes) in terminals

1.17.0 has roughly (vim cursor does not follow mouse):

set mouse=v     " Visual mode

It would be nice to have this as a "mouse option" in Settings. Once downgrading to 1.16.0, to prevent auto upgrade, I have to disalbe auto upgrade for all extensions, which is not a long-term solution.

berknam commented 4 years ago

This behaviour is very frustrating, being obliged to super carefully middle click on the line you activated the insert (vim mode) to properly paste. For the left mouse click, I can cope with it. But for the middle (paste) click, this really breaks the workflow.

@Pivert This is a different issue and it's not related to this extension. It's an issue in vscode. Check the issue #5065 to better understand it. Maybe you should try to open a feature request for that on vscode.

As for the rest of the people having issues after version 1.17.0 there is now a new version 1.17.1 that might fix some of the issues you're facing. Try updating to that one and see if it works now.

johns1342 commented 4 years ago

I am facing the opposite issue. I don't know why but my cursor position does not update when I click at some other location in normal mode. When I go back to insert mode, the cursor goes back to where it was before click. I do not want this

This appears to be fixed in 1.17.1 (see issue #5212), released today. It seems like most of us found our way here trying to figure out how to resolve #5212.

Dieterbe commented 4 years ago

strangely the behavior requested in #5212 is not how vim works at all... the behavior asked for here, is, however.

junekhan commented 4 years ago

Hi, I guess I have a new problem now with 1.17.1, when I navigate back or forward, the cursor seemingly moves as I go, however, once I start moving the cursor, it won't start from where the cursor is but the point I started navigating.

apolzon commented 4 years ago

I’ve also noticed some weird behavior when using change-word and change-to-letter commands in the latest version where a seemingly random character will be removed several words away from where my cursor is. I haven’t been able to nail down exactly what scenarios cause it but if I can figure that out I’ll be happy to log a more detailed report.

None of these problems were present prior to 1.17 - I have to wonder what issue in the vim plugin needed fixing that has resulted in these repeated regressions against expected behavior.

berknam commented 4 years ago

@junekhan

Hi, I guess I have a new problem now with 1.17.1, when I navigate back or forward, the cursor seemingly moves as I go, however, once I start moving the cursor, it won't start from where the cursor is but the point I started navigating.

@apolzon

I’ve also noticed some weird behavior when using change-word and change-to-letter commands in the latest version where a seemingly random character will be removed several words away from where my cursor is. I haven’t been able to nail down exactly what scenarios cause it but if I can figure that out I’ll be happy to log a more detailed report.

None of these problems were present prior to 1.17 - I have to wonder what issue in the vim plugin needed fixing that has resulted in these repeated regressions against expected behavior.

Both your situations are probably related to #5221 and might be fixed with PR #5250. If any of you can test that PR please post your feedback on that PR thread.

iw17 commented 3 months ago

Did u mean to disable cursor repositioning on mouse click operations on the text editor? I'm also a Vim user and I found it much frustrating if the cursor jumped elsewhere when I mistakenly clicked the text editor. I'm developing an extension to block it and about to complete it in a month.

iw17 commented 3 months ago

Did u mean to disable cursor repositioning on mouse click operations on the text editor? I'm also a Vim user and I found it much frustrating if the cursor jumped elsewhere when I mistakenly clicked the text editor. I'm developing an extension to block it and about to complete it in a month.

Pre-release: https://github.com/iw17/disable-mouse-for-vim

Welcome to create issues and/or PRs. In Sep I'll write docs for it and try to fix the bugs found.