-
-
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
Add next occurence in insert and normal mode is limited to a maximum of 2 cursors #1467
Comments
This DOES work without making that change to your settings, right? |
@johnfn the change to the configuration is only necessary to trigger _Add next occurrence through the default shortcut (however without it it could still be activated through other means such as the menu item). I will edit the issue to be clearer in this regard so that no further misunderstandings occurs . |
cmd-d works perfectly for me on OSX, no configuration changes required! Do you not experience the same? |
Yea I would not recommend that configuration change since I think we are handling it better for our usage, I was just saying it could be tried |
@johnfn and @xconverge |
Yea that should be a separate bug report, should be pretty straightforward! |
I created such an issue before(#1311) for the |
|
Saw this issue was closed out but was it fixed? I still can't use "Add next occurrence" in insert mode, same issue with only selecting two matches in insert mode. It only works in normal/visual mode for me. |
@jsonMartin How are you adding next occurrence? (and have you updated to version 0.7.1?) The issue you described in the other issue sounds like the exact issue I fixed. |
Hey @Chillee, thanks for the quick response! Yeah, I'm running on version 0.7.1. I'm attaching a copy of the text I posted over in the "multi cursor feedback" thread, but long story short I have tried doing it with my mouse at the menu bar on top of the screen, and with multiple different keyboard shortcuts mapped to "Add Next Occurrence". Also fiddled with the settings, nothing really helped. Multiple cursors and "Select All Occurrences" work fine in insert mode. |
@jsonMartin Can you try We should have fixed it in version 0.7.1 |
Actually, sorry, I am able to reproduce this. However, I am a little bit about your gif. Are you using a method of adding next occurence that's different from the default keybinding? The issue happens when the word that you're matching on is also a substring of another word. The thing that's messing it up in your gif is key and licenseKey. If you have something like
it should add cursors up until you get to licenseKey. The reason is that we can't really handle selections in insert mode (which |
Yeah, that's Command + D right? That's what I was actually doing in the demo above to try to select the next matching item. I have another binding for Add Next Occurrence since Cmd+D was bound to "Duplicate line", but that wasn't working either. I rebound Cmd+D back to Add Next Occurrence to test this, and no change in behavior. Also played around with the "extension.vim_cmd+d" keybindings as well to no avail |
In your case, I think it's the dot right after key. Could you try it on a blank file with nothing after the words? And definitely open up an issue. This is a bug. :) |
@jsonMartin Unluckily, I don't think so. I'm not really sure how to fix the first one (and I'm not sure it's worth spending the time to do so, since I doubt people use it much).
and it doesn't work in normal or insert mode? Or do you mean something more like your original example, where you have
? The third one is bizarre, I'll have to take a closer look at that one. I know how to fix the 4th one. I should be able to fix them soon, and we're planning on pushing out a release in a couple days, so you shouldn't have to wait too long. |
Haha. While fixing these bugs, I actually found a bug in the default VSCode functionality.
If you press |
Alright I fixed the main issues over here: #1748 So when you have time to make an issue, I'll merge the PR. Actually I'll just make the issue myself. |
Awesome, thanks @Chillee! This is why I love this plugin, ya'll are on top of it. No problem about point #1, if it works with keyboard shortcut and not menu, that's fine with me. I was only using the menu to test. To answer your question about the second issue, it's like my original example when I have "key" vs "licenseKey". In the GIF I posted above, when I'm in insert mode and using the keyboard shortcut to add additional occurrences, it won't select them all. If you notice, the first 3 lowercase "key" are selected. Then there are two "licenseKey" entries that are correctly skipped over, and the 4th lowercase "key" is added. But after keeping to hit the shortcut to add more occurrences, no more will be added. Looks like that's because of the period, that breaks all additional matches, when I put a space before the period it continues to match just fine. (This is what I assume your PR fixes) |
@Chillee Here's one more data point / issue I uncovered in addition to the dot breaking additional occurrences. When in Insert Mode and Match Case is OFF, no more occurrences can be added after the first case difference. When case is ON, it proceeds fine past the case difference. It works fine in Normal mode. Not sure if this particular issue was fixed by your PR, but this example might help illustrate what I'm talking about. If you notice here, when Match case is OFF in Insert Mode it breaks at the first licenseKey and won't add any more after: |
I think the cause is that key is a substring, not that key is uppercase. For example,
Doesn't work for me. And neither does
However, when the key isn't a substring, but there is a case difference, it works. For example,
works fine. |
Ah @Chillee , you're right! It doesn't matter whether it is uppercase or not, it is based on substring. So if "Match Whole Word" option is on, it will correctly skip "licensekey" or "licenseKey" while in insert mode. So the problem then is that when I switch back over to normal or visual mode, "match whole word" is causing the cursor to go backwards; this happens when using "gc" command or Add Next Occurrence keyboard shortcut. However, when I manually highlight the desired word (whether with a mouse, or keyboard) and then add next occurrence (rather than just pressing the shortcut in the middle of the word), it seems to find all the matches OK! The big caveat to this method I'm seeing is that after selecting the matching occurrences and trying to change or delete them, it is removing the character directly to the right (whether that's a space, or a period). To correctly select the whole word in visual/normal mode, the cursor has to be to the right of the word, which is why I believe when multiple cursors are added it's deleting the extra character — the only way I've found around this is that after selecting all occurrences in this mode, to hit the left arrow so it moves the cursor back before changing or deleting. If that doesn't make sense, please let me know and I can show an example. I assume that the intended behavior is to be able to press the add next occurrence shortcut and cursors should be added in the same positions and edit the same selection of text no matter which mode the user is in. |
@jsonMartin Yep, you're right. I think I've fixed all the bugs on master except for the "whole word" one. I'll need to take another look at that one to figure out how to handle it. |
Awesome, thanks for all the hard work on this. Much appreciated, cheers! |
@jsonMartin We just pushed out a new release, so try that and see if that fixes your issues! Note: We swapped around |
@Chillee Just checked out the new version, and looks like Insert mode multiple cursors is working perfectly for me now, fantastic! Thank you so much! I'm still seeing that bug in normal/visual mode on the new version however (which is what I think you mentioned above in your comment about the "whole word" bug). Here's an example of what it looks like on my end just to be clear: |
Please thumbs-up 👍 this issue if it personally affects you! You can do this by clicking on the emoji-face on the top right of this post. Issues with more thumbs-up will be prioritized.
What did you do?
Go to
either normal orinsert mode and press Add next occurence more than two times.For instance press it four times for the following text (the pipe
|
represents a cursor)What did you expect to happen?
I expected a new cursor to be added for every press.
What happened instead?
Only one new cursor is created, and after that Add next occurrence no longer adds cursors or seems to do anything.
Technical details:
Additional notes
Strangely enough it works on visual mode. Curiously, more than two cursors can be added through other commands such as Select all occurrences or
alt-click
The
Cmd-d
shortcut seems to be disabled by default while in insert mode, however it seems that can be restored by adding"vim.handleKeys": { "<D-d>":false}
to your configuration (This however breaks normal mode by limiting it to two cursors).The text was updated successfully, but these errors were encountered: