atom / snippets

Atom snippets package
MIT License
205 stars 100 forks source link

Nested tab stops now expand incorrectly #266

Closed dead-claudia closed 6 years ago

dead-claudia commented 6 years ago

Prerequisites

Description

[Description of the issue]

Steps to Reproduce

  1. Add a snippet with the body '() => ${1:\\{$2\\}}'
  2. Open a new file
  3. Change to a language where that snippet will be in scope
  4. Start to type it and hit tab to expand it

Expected behavior: [What you expect to happen]

It to expand like this with the brackets selected:

() => {}

Actual behavior: [What actually happens]

It expands like this, with the brackets selected:

() => {[object Object]}

Reproduces how often: [What percentage of the time does it reproduce?]

100% of the time

Versions

You can get this information from copy and pasting the output of atom --version and apm --version from the command line. Also, please include the OS and what version of the OS you're running.

Atom v1.25.0 on macOS 64-bit. This bug did not exist in v1.24.1.

Additional Information

Any additional information, configuration or data that might be necessary to reproduce the issue.

nemoDreamer commented 6 years ago

I have a bunch of snippets where a group references another group:

'.source.js':
    'Console Log':
        'prefix': 'cl'
        'body': '$3console.${2:log}($1);$0'
    'Console Log (verbose)':
        'prefix': 'cll'
        'body': "$4console.${3:log}('${2:$1}', $1);$0"
    'Console Log (labeled, verbose)':
        'prefix': 'clll'
        'body': "$5console.${4:log}('$1: ${3:$2}', $2);$0"

Typing cll ⇥ and typing something would result in 2 cursors:

console.log("myMysteryHash|", myMysteryHash|);

But now, it only does

console.log("[object Object]", myMysteryHash|);

I do not see the ${2:$1} pattern mentioned anywhere in the snippet docs. Was I just taking advantage of something I shouldn't have?

Could there be a backreference format instead, like ${2:\\1}?

joefitzgerald commented 6 years ago

This is definitely an issue; it's affecting go-plus autocomplete snippet expansion:

kapture 2018-04-09 at 16 00 06

screen shot 2018-04-09 at 4 02 13 pm

savetheclocktower commented 6 years ago

Oddly enough, this usage had no coverage in the tests. #267 ought to fix it.

rsese commented 6 years ago

Thanks for the report @isiahmeadows, just noting that I can reproduce on macOS 10.12.6 with 1.26.0-beta1 but it's not reproducible on 1.24.1 like you mentioned.

dead-claudia commented 6 years ago

@rsese Thanks! (It kind of didn't help that it broke some of my most frequently used snippets - I noticed within minutes of upgrading and about 36 hours from when it was first released.)

jasonrudolph commented 6 years ago

Fixed in #267