Skip to content

Commit d56121f

Browse files
committed
Update hashtable scopes
1 parent a9138a4 commit d56121f

File tree

2 files changed

+54
-33
lines changed

2 files changed

+54
-33
lines changed

PowerShell.sublime-syntax

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,22 @@ contexts:
207207
- match: \}
208208
scope: punctuation.section.braces.end.powershell
209209
pop: 1
210-
- match: \b(['"]?)(\w+)(['"]?)\s*(=)\s*
211-
scope: meta.hashtable.assignment.powershell
210+
- match: \b(({{single_quote}}){{identifier_simple}}({{single_quote}}))\s*(=)\s*
212211
captures:
213-
1: punctuation.definition.string.begin.powershell
214-
2: variable.other.readwrite.powershell
212+
1: meta.mapping.key.powershell string.quoted.single.powershell
213+
2: punctuation.definition.string.begin.powershell
215214
3: punctuation.definition.string.end.powershell
216-
4: keyword.operator.assignment.powershell
215+
4: punctuation.separator.key-value.powershell
216+
- match: \b(({{double_quote}}){{identifier_simple}}({{double_quote}}))\s*(=)\s*
217+
captures:
218+
1: meta.mapping.key.powershell string.quoted.double.powershell
219+
2: punctuation.definition.string.begin.powershell
220+
3: punctuation.definition.string.end.powershell
221+
4: punctuation.separator.key-value.powershell
222+
- match: \b({{identifier_simple}})\s*(=)\s*
223+
captures:
224+
1: meta.mapping.key.powershell string.unquoted.powershell
225+
2: punctuation.separator.key-value.powershell
217226
- include: expressions
218227

219228
subexpressions:

Tests/syntax_test_PowerShell.ps1

Lines changed: 40 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -68,24 +68,25 @@ using namespace System.Management.Automation
6868
# ^^^^^^^^ variable.parameter
6969
#Requires -Modules PSWorkflow, @{ModuleName="PSScheduledJob"; ModuleVersion="1.0.0.0"}
7070
# <- punctuation.definition.keyword
71-
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.requires
71+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.requires
7272
#^^^^^^^^ keyword.control.import.require
7373
# ^^^^^^^^ variable.parameter
7474
# ^ punctuation.separator
75-
# ^^^^^^^^^^ meta.requires meta.hashtable variable.other.readwrite
76-
# ^ meta.requires meta.hashtable
77-
# ^^^^^^^^^^^^^^^^ meta.requires meta.hashtable string.quoted.double
78-
# ^ meta.requires meta.hashtable punctuation.terminator.statement
79-
# ^^^^^^^^^^^^^ meta.requires meta.hashtable variable.other.readwrite
80-
# ^ meta.requires meta.hashtable
81-
# ^^^^^^^^^ meta.requires meta.hashtable string.quoted.double
75+
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.hashtable.powershell
76+
# ^^^^^^^^^^ meta.mapping.key string.unquoted
77+
# ^ punctuation.separator.key-value.powershell
78+
# ^^^^^^^^^^^^^^^^ string.quoted.double
79+
# ^ punctuation.terminator.statement
80+
# ^^^^^^^^^^^^^ meta.mapping.key string.unquoted
81+
# ^ punctuation.separator.key-value.powershell
82+
# ^^^^^^^^^ string.quoted.double
8283

8384
:label1
8485
# ^^^^^^^ entity.name.label.powershell
8586
# ^ punctuation.definition.label.powershell
8687

8788
throw "Do not run this file!"
88-
# <- keyword.control
89+
# <- keyword.control.exception
8990
# ^^^^^^^^^^^^^^^^^^^^^^^ string.quoted.double
9091

9192
# Stop parsing
@@ -241,33 +242,44 @@ $properties = @{
241242
# ^ keyword.other.hashtable.begin
242243
# ^ punctuation.section.braces.begin
243244
Name = 'Name'
244-
# <- meta.hashtable meta.hashtable.assignment variable.other.readwrite
245-
# ^ meta.hashtable meta.hashtable.assignment keyword.operator.assignment
246-
# ^ meta.hashtable string.quoted.single
245+
#^^^^^^^^^^^^^^^^^^^^^ meta.hashtable.powershell
246+
# ^^^^ meta.mapping.key.powershell string.unquoted.powershell
247+
# ^ punctuation.separator.key-value.powershell
248+
# ^^^^^^ meta.string.powershell string.quoted.single.powershell
249+
# ^ punctuation.definition.string.begin.powershell
250+
# ^ punctuation.definition.string.end.powershell
247251
Something = $else
248252
#^^^^^^^^^^^^^^^^^^^^ meta.hashtable.powershell
249-
# ^^^^^^^^^^^^ meta.hashtable.assignment.powershell
250-
# ^^^^^^^^^ variable.other.readwrite.powershell
251-
# ^ keyword.operator.assignment.powershell
253+
# ^^^^^^^^^ meta.mapping.key.powershell string.unquoted.powershell
254+
# ^ punctuation.separator.key-value.powershell
252255
# ^^^^^ variable.other.readwrite.powershell
253256
# ^ punctuation.definition.variable.powershell
254257
Number = 16
255-
# <- meta.hashtable meta.hashtable.assignment variable.other.readwrite
256-
# ^ meta.hashtable meta.hashtable.assignment keyword.operator.assignment
257-
# ^^ meta.hashtable meta.number.integer.decimal constant.numeric.value
258+
#^^^^^^^^^^^^^^^^^ meta.hashtable.powershell
259+
# ^^^^^^ meta.mapping.key.powershell string.unquoted.powershell
260+
# ^ punctuation.separator.key-value.powershell
261+
# ^^ meta.number.integer.decimal.powershell constant.numeric.value.powershell
258262
from = 'hello world'
259-
# <- meta.hashtable meta.hashtable.assignment variable.other.readwrite
260-
# ^ meta.hashtable meta.hashtable.assignment keyword.operator.assignment
261-
# ^^^^^^^^^^^^^ meta.hashtable string.quoted.single
263+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.hashtable.powershell
264+
# ^^^^ meta.mapping.key.powershell string.unquoted.powershell
265+
# ^ punctuation.separator.key-value.powershell
266+
# ^^^^^^^^^^^^^ meta.string.powershell string.quoted.single.powershell
267+
# ^ punctuation.definition.string.begin.powershell
268+
# ^ punctuation.definition.string.end.powershell
262269
hash = @{
263-
# <- meta.hashtable meta.hashtable.assignment variable.other.readwrite
264-
# ^ meta.hashtable meta.hashtable.assignment keyword.operator.assignment
265-
# ^ keyword.other.hashtable.begin
266-
# ^ punctuation.section.braces.begin
270+
#^^^^^^^^^^^^^^^^^ meta.hashtable.powershell
271+
# ^^^^ meta.mapping.key.powershell string.unquoted.powershell
272+
# ^ punctuation.separator.key-value.powershell
273+
# ^^ meta.hashtable.powershell
274+
# ^ keyword.other.hashtable.begin.powershell
275+
# ^ punctuation.section.braces.begin.powershell
267276
hello = 'world'
268-
# <- meta.hashtable meta.hashtable.assignment variable.other.readwrite
269-
# ^ meta.hashtable meta.hashtable.assignment keyword.operator.assignment
270-
# ^^^^^^^ meta.hashtable string.quoted.single
277+
#^^^^^^^^^^^^^^^^^^^^^^ meta.hashtable.powershell meta.hashtable.powershell
278+
# ^^^^^ meta.mapping.key.powershell string.unquoted.powershell
279+
# ^ punctuation.separator.key-value.powershell
280+
# ^^^^^^^ meta.string.powershell string.quoted.single.powershell
281+
# ^ punctuation.definition.string.begin.powershell
282+
# ^ punctuation.definition.string.end.powershell
271283
}
272284
# <- punctuation.section.braces.end
273285
}

0 commit comments

Comments
 (0)