mirror of
https://github.com/atom/atom.git
synced 2026-01-23 22:08:08 -05:00
Support loading CSON snippets from TextMate bundles
This commit is contained in:
4
spec/fixtures/packages/package-with-a-cson-grammar.tmbundle/Snippets/test.cson
vendored
Normal file
4
spec/fixtures/packages/package-with-a-cson-grammar.tmbundle/Snippets/test.cson
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
'name': 'Really'
|
||||
'scope': 'source.alot'
|
||||
'tabTrigger': 'really'
|
||||
'content': 'I really like $1 alot$0'
|
||||
@@ -20,8 +20,10 @@ module.exports =
|
||||
|
||||
continue if fs.base(snippetsPath).indexOf('.') is 0
|
||||
try
|
||||
if object = fs.readPlist(snippetsPath)
|
||||
snippets.push(object) if object
|
||||
if fs.extension(snippetsPath) is '.cson' and object = fs.readObject(snippetsPath)
|
||||
snippets.push(object)
|
||||
else if object = fs.readPlist(snippetsPath)
|
||||
snippets.push(object)
|
||||
else
|
||||
logWarning()
|
||||
catch e
|
||||
|
||||
@@ -5,6 +5,7 @@ Buffer = require 'buffer'
|
||||
Editor = require 'editor'
|
||||
_ = require 'underscore'
|
||||
fs = require 'fs'
|
||||
Package = require 'package'
|
||||
|
||||
describe "Snippets extension", ->
|
||||
[buffer, editor, editSession] = []
|
||||
@@ -295,6 +296,22 @@ describe "Snippets extension", ->
|
||||
expect(Worker.prototype.terminate).toHaveBeenCalled()
|
||||
expect(Worker.prototype.terminate.calls.length).toBe 1
|
||||
|
||||
it "loads CSON snippets from TextMate packages", ->
|
||||
jasmine.unspy(LoadSnippetsTask.prototype, 'loadTextMateSnippets')
|
||||
snippets.loaded = false
|
||||
task = new LoadSnippetsTask(snippets)
|
||||
task.packages = [Package.build(fixturesProject.resolve('packages/package-with-a-cson-grammar.tmbundle'))]
|
||||
task.start()
|
||||
|
||||
waitsFor "CSON snippets to load", 5000, -> snippets.loaded
|
||||
|
||||
runs ->
|
||||
snippet = syntax.getProperty(['.source.alot'], 'snippets.really')
|
||||
expect(snippet).toBeTruthy()
|
||||
expect(snippet.prefix).toBe 'really'
|
||||
expect(snippet.name).toBe 'Really'
|
||||
expect(snippet.body).toBe "I really like alot"
|
||||
|
||||
describe "snippet body parser", ->
|
||||
it "breaks a snippet body into lines, with each line containing tab stops at the appropriate position", ->
|
||||
bodyTree = snippets.getBodyParser().parse """
|
||||
|
||||
Reference in New Issue
Block a user