Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Commit 51143b8

Browse files
committed
Allows variables starting with underscores
1 parent 6879ea1 commit 51143b8

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

grammars/puppet.cson

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@
410410
'captures':
411411
'1':
412412
'name': 'punctuation.definition.variable.puppet'
413-
'match': '(\\$)([a-zA-Zx7f-xff\\$]|::)([a-zA-Z0-9_x7f-xff\\$]|::)*\\b'
413+
'match': '(\\$)([a-zA-Zx7f-xff\\$_]|::)([a-zA-Z0-9_x7f-xff\\$]|::)*\\b'
414414
'name': 'variable.other.readwrite.global.puppet'
415415
}
416416
{

spec/puppet-spec.coffee

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,11 @@ describe "Puppet grammar", ->
4747
{tokens} = grammar.tokenizeLine("package {$foo:}")
4848
expect(tokens[0]).toEqual value: 'package', scopes: ['source.puppet', 'meta.definition.resource.puppet', 'storage.type.puppet']
4949
expect(tokens[2]).toEqual value: '$foo', scopes: ['source.puppet', 'meta.definition.resource.puppet', 'entity.name.section.puppet']
50+
51+
it "tokenizes regular variables", ->
52+
{tokens} = grammar.tokenizeLine('$foo')
53+
expect(tokens[0]).toEqual value: '$', scopes: ['source.puppet', 'variable.other.readwrite.global.puppet', 'punctuation.definition.variable.puppet']
54+
expect(tokens[1]).toEqual value: 'foo', scopes: ['source.puppet', 'variable.other.readwrite.global.puppet']
55+
{tokens} = grammar.tokenizeLine('$_foo')
56+
expect(tokens[0]).toEqual value: '$', scopes: ['source.puppet', 'variable.other.readwrite.global.puppet', 'punctuation.definition.variable.puppet']
57+
expect(tokens[1]).toEqual value: '_foo', scopes: ['source.puppet', 'variable.other.readwrite.global.puppet']

0 commit comments

Comments
 (0)