@@ -274,7 +274,7 @@ module.exports = {
274274 } catch ( e ) {
275275 const message = `\
276276 Unable to watch path: \`snippets.cson\`. Make sure you have permissions
277- to the \`~/.atom \` directory and \`${ userSnippetsPath } \`.
277+ to the \`~/.pulsar \` directory and \`${ userSnippetsPath } \`.
278278
279279 On linux there are currently problems with watch sizes. See
280280 [this document][watches] for more info.
@@ -537,7 +537,7 @@ module.exports = {
537537
538538 let targetSnippet = null
539539 for ( let snippet of Object . values ( snippets ) ) {
540- if ( snippet . command === command && snippet . packageName === packageName ) {
540+ if ( snippet . id === attributes . id ) {
541541 targetSnippet = snippet
542542 break
543543 }
@@ -555,17 +555,7 @@ module.exports = {
555555 return event . abortKeyBinding ( )
556556 }
557557
558- this . getStore ( editor ) . observeHistory ( {
559- undo : event => { this . onUndoOrRedo ( editor , event , true ) } ,
560- redo : event => { this . onUndoOrRedo ( editor , event , false ) }
561- } )
562- this . findOrCreateMarkerLayer ( editor )
563- editor . transact ( ( ) => {
564- const cursors = editor . getCursors ( )
565- for ( const cursor of cursors ) {
566- this . insert ( targetSnippet , editor , cursor )
567- }
568- } )
558+ this . expandSnippet ( editor , targetSnippet )
569559 }
570560
571561 let disposable = atom . commands . add (
@@ -770,6 +760,22 @@ module.exports = {
770760 }
771761 } ,
772762
763+ expandSnippet ( editor , snippet ) {
764+ this . getStore ( editor ) . observeHistory ( {
765+ undo : event => { this . onUndoOrRedo ( editor , event , true ) } ,
766+ redo : event => { this . onUndoOrRedo ( editor , event , false ) }
767+ } )
768+
769+ this . findOrCreateMarkerLayer ( editor )
770+
771+ editor . transact ( ( ) => {
772+ const cursors = editor . getCursors ( )
773+ for ( const cursor of cursors ) {
774+ this . insert ( snippet , editor , cursor )
775+ }
776+ } )
777+ } ,
778+
773779 expandSnippetsUnderCursors ( editor ) {
774780 const snippet = this . snippetToExpandUnderCursor ( editor )
775781 if ( ! snippet ) { return false }
@@ -883,7 +889,7 @@ module.exports = {
883889 if ( cursor == null ) { cursor = editor . getLastCursor ( ) }
884890 if ( typeof snippet === 'string' ) {
885891 const bodyTree = this . getBodyParser ( ) . parse ( snippet )
886- snippet = new Snippet ( { name : '__anonymous' , prefix : '' , bodyTree, bodyText : snippet } )
892+ snippet = new Snippet ( { id : this . snippetIdCounter ++ , name : '__anonymous' , prefix : '' , bodyTree, bodyText : snippet } )
887893 }
888894 return new SnippetExpansion ( snippet , editor , cursor , this )
889895 } ,
0 commit comments