Skip to content

Bug in cursor location within user snippets #11742

Closed

Description

  • VSCode Version: 1.5.0 & 1.5.1
  • OS Version: OS X 10.11.6 (15G1004)

Steps to Reproduce:

  1. Add the following snippet to the javascript.json user snippets file:
{
     "Print to console": {
        "prefix": "log",
        "body": [
            "console.log('$1');"
        ],
        "description": "Log output to console"
    }
}
  1. Then open an .js file and type "log" ENTER to insert the snippet.

Before the update of 1.5.0 the cursor appeared at $1 console.log('|'); now at the end of the line console.log('');|

Activity

  1. ramya-rao-a commented on Sep 9, 2016

    @ramya-rao-a
    Contributor

    Richard Ruiter (@richardruiter) I tried in OS X El Capitan 10.11.6 and Windows 10 with VS Code 1.5.1 and can't repro this. The cursor ends up in the right place.

    Are you able to see this when extensions are disabled? Try running code --disable-extensions

    Johannes Rieken (@jrieken) Assigning to you since you were the last person touching the snippets side of things as far as I know

  2. added
    info-needed
    on Sep 9, 2016
  3. jrieken commented on Sep 9, 2016

    @jrieken
    Contributor

    same here - failing to reproduce. Richard Ruiter (@richardruiter) Please update your steps/sample

  4. ITSecMedia commented on Sep 9, 2016

    @ITSecMedia

    This very annoying bug happens on my machine too.
    Recognised in markdown snippets.
    Windows 10 x64 since Version 1.5.0 up to 1.5.1.

  5. jrieken commented on Sep 9, 2016

    @jrieken
    Contributor

    Norman Eckstein (@ITSecMedia) It would help if you include reproducible steps and the snippet you are completing

  6. jrieken commented on Sep 9, 2016

    @jrieken
    Contributor

    Just to make sure are talking about the same thing. This is what I see and believe is proper.

    Markdown bold snippet
    sep-09-2016 10-20-19

    Custom snippet as shown above
    sep-09-2016 10-20-32

  7. ITSecMedia commented on Sep 9, 2016

    @ITSecMedia

    Sorry, I expected the bug is obvious.

    Just opened VSCode, started new markdown file using this snippet.

    The defined tab-stops in the snippets doesn't work anymore. When I have a text like this.

    example [example](sc <-shortcode) example example example CURSOR HERE

    The cursor is not placed at position $1 inside the placed snippet but rather at the end of line.

    {
         "ShortCode": {
            "prefix": "sc",
            "body": [
                "{{% url_**$1** %}}"
            ],
            "description": "Insert ShortCode"
        }
    }
    
  8. added
    bug
    important
    and removed
    info-needed
    on Sep 9, 2016
  9. jrieken commented on Sep 9, 2016

    @jrieken
    Contributor

    Thanks. I can reproduce now

  10. jrieken commented on Sep 9, 2016

    @jrieken
    Contributor

    As a workaround you can use tab completion (settings > "editor.tabCompletion": true) which isn't affected by this.

  11. 18 remaining items

  12. cauldyclark15 commented on Sep 12, 2016

    @cauldyclark15

    Hello, I am still having the issue same with #11782, cursor is not between quotes after autocomplete on HTML. I just updated to VS Code version 1.5.1, and using Windows 7. I am new here so if you need additional information from me, please advice.

  13. jrieken commented on Sep 12, 2016

    @jrieken
    Contributor

    JC Castaneda (@cauldyclark15) You need to wait for 1.5.2 or built from source

  14. cauldyclark15 commented on Sep 12, 2016

    @cauldyclark15

    Johannes Rieken (@jrieken) Thank you for your response, I understand now.

  15. dburles commented on Sep 20, 2016

    @dburles

    Since this fix for some reason snippets only work once

  16. dburles commented on Feb 15, 2017

    @dburles

    Still seeing the above issue

  17. ramya-rao-a commented on Feb 16, 2017

    @ramya-rao-a
    Contributor

    David Burles (@dburles) I am able to confirm that the issue described above in #11742 (comment) and #11742 (comment) are working as expected.

    Are you referring to these linked issues or your earlier comment of "snippets only work once" ?

  18. dburles commented on Feb 16, 2017

    @dburles

    Sorry yeah the issue with snippets only working once. It's a strange one and I just haven't had time to dig into it. Basically I'll be able to write 'log[tab]' and have it expand to console.log(...) just fine but only one time, until I restart vscode.

  19. ramya-rao-a commented on Feb 16, 2017

    @ramya-rao-a
    Contributor

    David Burles (@dburles) Can you create a new issue for that since this issue is more about the cursor position after snippet expansion?

  20. dburles commented on Feb 16, 2017

    @dburles

    Sure. Though I do recall that it wasn't a problem until this fix was released so it's possibly related.

  21. ramya-rao-a commented on Feb 16, 2017

    @ramya-rao-a
    Contributor

    David Burles (@dburles) In that case, do add a note about it in the new issue. Thanks!

  22. unChartedZone commented on Feb 16, 2017

    @unChartedZone

    This used to be an issue on osx, primarily with HTML files, this occurred right after a certain release of vscode, I think 1.7.0, but an update to 1.7.1 fixed it, I'm guessing Windows didn't get the same fix

  23. alanldawkins commented on Mar 17, 2017

    @alanldawkins

    I have the same problem too, snippets only work for $1 and the it skip all next to the end of the snippet, if you've set $0, it will be $1 -> $0, all others will be skipped too. Both on Windows( my version is enterprise 10) and Ubuntu ( 16.04.2).
    Since this issue I've give up snippets for a long time. : (

  24. 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

bugimportantsnippetsverified

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions