Skip to content
This repository was archived by the owner on Jun 2, 2023. It is now read-only.

Fix comparison operator matching #27

Merged
merged 3 commits into from
Nov 25, 2014
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
2 changes: 1 addition & 1 deletion grammars/powershell.cson
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
'name': 'keyword.operator.bitwise.powershell'
}
{
'match': '-eq|-ceq|-ieq|-lt|-gt|-le|-ge|-ne|-notlike|-like|-match|-notmatch|-contains|-notcontains|-in|-notin|-replace'
'match': '\\B(?i:(-eq|-ceq|-ieq|-lt|-gt|-le|-ge|-ne|-notlike|-like|-match|-notmatch|-contains|-notcontains|-in|-notin|-replace))\\b'
'name': 'keyword.operator.comparison.powershell'
}
{
Expand Down
16 changes: 13 additions & 3 deletions spec/powershell-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,19 @@ describe "PowerShell grammar", ->
{tokens} = grammar.tokenizeLine operator
expect(tokens[0]).toEqual value: operator, scopes: ["source.powershell","keyword.operator.comparison.powershell"]

it "tokenizes comparison operators regardless of case", ->
for operator in comparisonOperators
{tokens} = grammar.tokenizeLine operator.toUpperCase()
expect(tokens[0]).toEqual value: operator.toUpperCase(), scopes: ["source.powershell","keyword.operator.comparison.powershell"]

it "will not tokenize the operators if there's more characters", ->
for operator in comparisonOperators
operatorPlus = operator + "ual"
{tokens} = grammar.tokenizeLine operatorPlus
expect(tokens.length).toBe(2)
expect(tokens[0]).not.toHaveScopes ["keyword.operator.comparison.powershell"]
expect(tokens[1]).not.toHaveScopes ["keyword.operator.comparison.powershell"]

describe "Automatic variables", ->
automaticVariables = [
"$null", "$true", "$false", "$$", "$?", "$^", "$_",
Expand Down Expand Up @@ -324,9 +337,6 @@ describe "PowerShell grammar", ->

it "escapes single quotes within a string", ->
{tokens} = grammar.tokenizeLine("$command = \'.\\myfile.ps1 -param1 `\'$myvar`\' -param2 whatever\'")
console.log tokens
console.log tokens[7]
console.log tokens[8]
expect(tokens[7]).toHaveScopes ["source.powershell", "constant.character.escape.powershell", "string.quoted.single.single-line.powershell"]
expect(tokens[8]).toHaveScopes ["source.powershell", "string.quoted.single.single-line.powershell"]

Expand Down