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

Expanding the snippet with multicursor is broken #4223

Closed
ganow opened this issue Oct 28, 2019 · 3 comments · Fixed by #4570
Closed

Expanding the snippet with multicursor is broken #4223

ganow opened this issue Oct 28, 2019 · 3 comments · Fixed by #4570

Comments

@ganow
Copy link

ganow commented Oct 28, 2019

Describe the bug
I am using the VSCodeVim/Vim plugin with the C/C++ plugin by Microsoft. When I enter for<tab>, the plugin expands the for-loop snippet. The behavior of modifying the iterating variable for this snippet seems to be broken. When I type j to replace i, the iterating variable becomes ij instead of j. I also could not delete the text properly.

Image from Gyazo

To Reproduce

  1. Install the C/C++ plugin by Microsoft
  2. Open a new C++ file
  3. Type for<tab>
  4. Type <tab> to select the iteration variable i
  5. Try to modify the variable

Expected behavior
As I mentioned in the Describe the bug section.
Also, I verified that this behavior did not happen when I disable the Vim plugin.

Screenshots
As I mentioned in the Describe the bug section.

Environment (please complete the following information):

  • VSCode (v.1.39.2)
  • Vim plugin (v1.11.3)
  • C/C++ plugin by Microsoft (v0.26.0)
  • OS: macOS Mojave (v10.14.6)

Additional context
None.

@nerdmax
Copy link

nerdmax commented Nov 10, 2019

+1

1 similar comment
@listenerri
Copy link
Contributor

+1

@cvaldev
Copy link
Contributor

cvaldev commented Jan 9, 2020

This behaviour happens on any snippet that uses multicursor, I don't believe it is linked to a particular language as I'm able to recreate it on every language I tried and even on my own custom global snippets.

J-Fields pushed a commit that referenced this issue Mar 27, 2020
Fixes multicursor snippets, and adds support for stuff like auto-bracketing and auto-completion on multicursor mode.

Backspace Support:
Makes range represent the selection at position. This way we delete the correct range rather than the primary selection as it was before these changes.

Multicursor Character Insert:
Makes multicursor text insertion behave like single cursor text insertion by ultimately using the default: type command rather than vscode.TextEditor.insert() which doesn't have support for snippet mode, auto completion, bracketing, etc.

To accomplish this, I've added an optional property (isMultiCursor) to InsertTextVSCodeTransformation which represents vimState.isMultiCursorat the time the transformation was created. This property is used to filter the multicursor transformations into multicursorTextTransformations.

Because the default: type command handles inserting the text into the correct cursor positions there's no need to repeat the transformation multiple times and we can just execute the command once, as long as we know all transformations are trying to do the same thing.

Fixes #4281, fixes #4223, fixes #3005, fixes #4522, fixes #4515, fixes #1946, fixes #3976
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants