diff --git a/grammars/powershell.cson b/grammars/powershell.cson index fa61a9f..596ec2d 100644 --- a/grammars/powershell.cson +++ b/grammars/powershell.cson @@ -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' } { diff --git a/spec/powershell-spec.coffee b/spec/powershell-spec.coffee index a840fcc..352ed2c 100644 --- a/spec/powershell-spec.coffee +++ b/spec/powershell-spec.coffee @@ -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", "$$", "$?", "$^", "$_", @@ -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"]