Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/snippets.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ module.exports =

parsedSnippetsForScopes: (scopeDescriptor) ->
unparsedSnippetsByPrefix = @scopedPropertyStore.getPropertyValue(@getScopeChain(scopeDescriptor), "snippets")
unless unparsedSnippetsByPrefix?
legacyScopeDescriptor = atom.config.getLegacyScopeDescriptorForNewScopeDescriptor?(scopeDescriptor)
if legacyScopeDescriptor?
unparsedSnippetsByPrefix = @scopedPropertyStore.getPropertyValue(@getScopeChain(legacyScopeDescriptor), "snippets")
unparsedSnippetsByPrefix ?= {}
snippets = {}
for prefix, attributes of unparsedSnippetsByPrefix
Expand Down
13 changes: 13 additions & 0 deletions spec/snippets-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,19 @@ describe "Snippets extension", ->
expect(snippets.snippetsForScopes(['.source.js'])['t1']).toBeTruthy()
expect(snippets.snippetsForScopes(['.source.js .nope.not-today'])['t1']).toBeFalsy()

if atom.config.setLegacyScopeAliasForNewScope?
it "reads snippets using the scope name's legacy alias if available", ->
Snippets.add __filename,
'.source.js':
"some snippet":
prefix: "t1"
body: "this is a test"

atom.config.setLegacyScopeAliasForNewScope('javascript', 'source.js')

snippets = Snippets.provideSnippets()
expect(snippets.snippetsForScopes(['javascript'])['t1'].name).toEqual('some snippet')

describe "when 'tab' is triggered on the editor", ->
beforeEach ->
Snippets.add __filename,
Expand Down