Skip to content

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

Closed

Description

@Tyriar
  • 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

Activity

  1. added
    emmet
    on May 30, 2017
  2. added
    bug
    on May 30, 2017
  3. 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[/+] on May 31, 2017
  4. ramya-rao-a commented on Jun 22, 2017

    @ramya-rao-a
    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.

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

  5. jrieken commented on Jun 22, 2017

    @jrieken
    Contributor

    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

  6. ramya-rao-a commented on Jun 22, 2017

    @ramya-rao-a
    Contributor

    Johannes Rieken (@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

  7. jrieken commented on Jun 22, 2017

    @jrieken
    Contributor

    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.

  8. ramya-rao-a commented on Jun 22, 2017

    @ramya-rao-a
    Contributor

    Thanks Johannes Rieken (@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
  9. ramya-rao-a commented on Jun 26, 2017

    @ramya-rao-a
    Contributor

    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
  10. Tyriar commented on Jun 29, 2017

    @Tyriar
    ContributorAuthor

    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.
  11. Tyriar commented on Jun 29, 2017

    @Tyriar
    ContributorAuthor

    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

  12. added
    important
    on Jun 29, 2017
  13. ramya-rao-a commented on Jun 29, 2017

    @ramya-rao-a
    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

  14. added
    verified
    on Jun 29, 2017
  15. locked and limited conversation to collaborators on Nov 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugemmetimportantverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions