Skip to content
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

Snippet is not working Properly #5240

Closed
grim-firefly opened this issue Sep 24, 2020 · 9 comments · Fixed by #5540
Closed

Snippet is not working Properly #5240

grim-firefly opened this issue Sep 24, 2020 · 9 comments · Fixed by #5540
Labels

Comments

@grim-firefly
Copy link

when i write a for loop using snipet's . when i press TAB key it's auto come to normal mode.
Screenshot from 2020-09-25 00-05-41

@JW9506
Copy link

JW9506 commented Sep 24, 2020

If you are using the latest 1.17 and seeing the bug, just downgrade to 1.16 manually

@grim-firefly
Copy link
Author

thanks a lot. i downgrade to 1.16.0 and it's worked perfectly 💯

If you are using the latest 1.17 and seeing the bug, just downgrade to 1.16 manually

@draivin
Copy link

draivin commented Sep 25, 2020

I'm hitting a similar issue with my extension hsnips, though it only happens when vscode's insertSnippet is called directly. You can see the related issue here draivin/hsnips#28.

@draivin
Copy link

draivin commented Sep 25, 2020

I just did a git bisect, which reveals that in my case this commit is the culprit: 35d06e6.

@berknam
Copy link
Contributor

berknam commented Sep 28, 2020

Whats happening here is that we've made a change that when we get a selection we go into visual mode (which is what happens in normal Vim).

When using snippets it creates a selection which goes into visual mode. Which shouldn't be any issue, one could just press c to change the current selected word(s) deleting that word(s) and going into insert mode and then write the new word(s) we want and press <Tab> to go to the next snippet placeholder. Now this here is the problem! We can't handle the <Tab> key (like explained on #5131) so there is no way of us knowing that the user pressed TAB to go to the next placeholder, so from VSCodeVim point of view the user is still in insert mode after pressing the operator c, and after they press <Tab> it goes to the next placeholder and it creates a selection again which changes mode to visual, but VSCodeVim still thinks it is in the middle of a ChangeOperator so then it doesn't do anything if you try to press 'c' again, you would have to press it twice in order to work.

Since we probably won't be able to fix the issue with TAB any time soon, I'm trying to find a way to detect a selection as being from a snippet so that we don't go into visual mode.

@J-Fields I'm working on this one, but any ideas are welcome.

@breemts
Copy link

breemts commented Oct 16, 2020

Something similar for me. When I do ctrl+f to search for something with 'VSCode search' in insert mode it still is in insert mode. But when I select find next and previous I'm back into normal mode.
This also seems to stack up. So when searching back and forth I have to press 'i' multiple times to get back into insert mode.

I have set "vim.useCtrlKeys": false,

@berknam
Copy link
Contributor

berknam commented Oct 16, 2020

Something similar for me. When I do ctrl+f to search for something with 'VSCode search' in insert mode it still is in insert mode. But when I select find next and previous I'm back into normal mode.
This also seems to stack up. So when searching back and forth I have to press 'i' multiple times to get back into insert mode.

I have set "vim.useCtrlKeys": false,

The is a different thing. When you do a search vscode selects the word. Recently a change was made that every time vscode creates a selection we go to visual mode. This is the same behavior as in normal Vim, except in normal Vim you can change it to go to SelectMode instead of VisualMode. Since select mode hasn't been implemented yet we go to visual mode, then you do as expected in visual mode, want to change the selected word press 'c', want to append to that selection press 'A', want to copy press 'y', want to delete press 'd', etc.

@jganetsk
Copy link

I'm trying to find a way to detect a selection as being from a snippet so that we don't go into visual mode.

Is there a jumpToNextSnippetPlaceholder event type?

@berknam
Copy link
Contributor

berknam commented Oct 30, 2020

I'm trying to find a way to detect a selection as being from a snippet so that we don't go into visual mode.

Is there a jumpToNextSnippetPlaceholder event type?

No. AFAIK there are no triggered events after a command being ran that the API exposes to the extensions.

I've created the PR #5540 to try and fix this, can any of you test it and post your feedback?

J-Fields pushed a commit that referenced this issue Nov 13, 2020
When in insert mode and inserting a snippet it will no longer change to visual mode, now it stays in "Insert Mode" or "Insert Mode - Multicursor"
Fixes #5240, fixes #5474, fixes #5538
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants