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

Wrap with abbreviation and Expand abbr commands do not work with multiple cursors #27621

Closed
Tyriar opened this issue May 30, 2017 · 9 comments
Closed
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug emmet Emmet related issues important Issue identified as high-priority verified Verification succeeded
Milestone

Comments

@Tyriar
Copy link
Member

Tyriar commented May 30, 2017

  • VSCode Version: Code - Insiders 1.13.0-insider (c2a17a7, 2017-05-30T05:12:15.312Z)
  • OS Version: Linux x64 4.10.0-21-generic
  • Extensions:
Extension Author Version
EditorConfig EditorConfig 0.9.3
lorem-ipsum Tyriar 1.0.0
sort-lines Tyriar 1.3.0
theme-sapphire Tyriar 0.2.1
vscode-svgviewer cssho 1.4.1
tslint eg2 0.15.0
git-project-manager felipecaputo 1.3.2
md-navigate jrieken 0.0.1
vscode-scss mrmlnc 0.6.2
seti-icons qinjia 0.1.3

#27316

Get into this state:

image

Wrap with abbreviation "a":

image

@Tyriar Tyriar added the emmet Emmet related issues label May 30, 2017
@ramya-rao-a ramya-rao-a added the bug Issue identified by VS Code Team member as probable bug label May 30, 2017
@ramya-rao-a ramya-rao-a added this to the May 2017 milestone May 30, 2017
@ramya-rao-a ramya-rao-a changed the title Wrap with abbreviation doesn't work with multiple cursors Wrap with abbreviation and Expand abbr commands do not work with multiple cursors May 31, 2017
@ramya-rao-a ramya-rao-a modified the milestones: June 2017, May 2017 May 31, 2017
@ramya-rao-a
Copy link
Contributor

Multi cursor now works for both Emmet: Expand Abbreviation and Emmet: Wrap with abbreviation command.

But once the commands get executed, the multi cursors are lost and the cursor is in the last snippet that got expanded.

@jrieken This is how I am inserting the snippets. What can I do to ensure that the multi cursor remain ?

@jrieken
Copy link
Member

jrieken commented Jun 22, 2017

Don't call insert in a loop over the selection but invoke it just once. First build all ranges and then call insert will all of them. That should do it, the ranges are being set as selection

@ramya-rao-a
Copy link
Contributor

@jrieken That will work if the same snippet has to be inserted in all ranges. But that is not the case here. We could technically have 3 different emmet abbr in 3 different locations

@jrieken
Copy link
Member

jrieken commented Jun 22, 2017

Then you cannot do it without manual work. Snippets, like all multi-cursor operations, insert the same text at all cursors. You could combine all emmet expansions into one snippets and that snippet would replace those three lines, the SnippetString and its builder functions might help you.

@ramya-rao-a
Copy link
Contributor

Thanks @jrieken

You could combine all emmet expansions into one snippets and that snippet would replace those three lines

You mean combine the text in between the lines as well into one big snippet? I'll re-visit this based on user feedback.

For now I am taking this approach

  • If abbreviation in all cursors are the same, the pass all ranges at once in a single call to editor.insertSnippet. All cursors will be maintained
  • Else call editor.insertSnippet for each range/abbreviation. A single cursor will remain in the last snippet that was entered

@ramya-rao-a
Copy link
Contributor

ramya-rao-a commented Jun 26, 2017

Note to verifier:

  • Test multi-cursor by trying to expand the same abbreviation at multiple cursors.
    - All abbreviations should expand
    - Cursor should be at the first tab stop of each expanded snippet
    - Further tabs should take you through each of the tabstops for each cursor
  • Test multi-cursor by trying to expand different abbreviation at different cursors.
    - All abbreviation should expand
    - Only the snippet at the last cursor will end up having its cursor maintained. Its a known issue

@Tyriar
Copy link
Member Author

Tyriar commented Jun 29, 2017

Same repro steps above, I get:

screen shot 2017-06-29 at 8 57 14 am

Problems:

  • The cursor is on the last line, tabbing through does not go to the abbr/content of the tags above.
  • A space and a tab is inserted in the middle of the tag. I thought it might be related but it reproduces with editor.autoIndent disabled.

@Tyriar Tyriar reopened this Jun 29, 2017
@Tyriar
Copy link
Member Author

Tyriar commented Jun 29, 2017

This actually applies to the non multiple cursor case as well, I think this is a bad regression:

screen shot 2017-06-29 at 10 06 53 am

@Tyriar Tyriar added the important Issue identified as high-priority label Jun 29, 2017
@ramya-rao-a
Copy link
Contributor

For the cursor issue in #27621 (comment), since the text being wrapped is different, the final snippets are different in which case it is not possible to preserve all the cursors as explained #27621 (comment)

The extra space and tab issue occurs only when the wrapping abbreviation is for an inline element (a, span etc).

Fixed with 605ee59

@mjbvz mjbvz added the verified Verification succeeded label Jun 29, 2017
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug emmet Emmet related issues important Issue identified as high-priority verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

4 participants