Why isn't doesn't this snippet work?


#1

My snippets file has 4 snippets that have the same scope, with different titles, triggers and bodies. For some reason the 2nd to last one isn’t triggering whenever I have my last snippet there also. Renaming the titles and triggers doesn’t fix this issue.

2nd to last snippet:

'.source.shell':
  "If Exists":
    'prefix': 'IfEx'
    'body':"""
    if [ -e /some/dir ]
    then
      ${1:echo "doing this"}
    else
      ${2:echo "It wasn't found"}
    fi
    """

Last snippet

'.source.shell':
  "If it Doesn't Exists":
    'prefix': '!IfEx'
    'body':"""
    if [ ! -e /some/dir ]
    then
      ${1:echo "doing this"}
    else
      ${2:echo "It was found"}
    fi
    """

Which version of Atom are I using?
0.189.0

What OS and version are I running?
Linux Mint 17.1 with the Linux 3.13.0-37-generic kernel

Do you have the Shadow DOM feature enabled?
Yes

Do I have the Emmet package installed?
No

Can I reproduce the issue after completely exiting Atom and restarting using atom --safe?
Yes


#2

CSON, like JSON, is an Object Notation. It consists of keys and structured values. If you specify two or more copies of the same key … the last copy overwrites the previous ones, not adds to it.

It sounds like you have:

'.source.shell':
  "If Exists":
    # snip
'.source.shell':
  "If it Doesn't Exists":
    #snip

Notice that you have two copies of the '.source.shell' key. If you change it to:

'.source.shell':
  "If Exists":
    # snip
  "If it Doesn't Exists":
    #snip

things will work fine.


#3

That works; thanks.


#4

Very few parsers check for this which is a real problem. I can’t think of a situation where you aren’t losing data when you have duplicates.