diff --git a/grammars/php.cson b/grammars/php.cson index a3e6868..bb89852 100644 --- a/grammars/php.cson +++ b/grammars/php.cson @@ -2759,7 +2759,7 @@ 'match': '\\\\(?:\\\\(?:\\\\[\\\\\']?|[^\'])|.)' 'name': 'constant.character.escape.php' 'sql-string-double-quoted': - 'begin': '"\\s*(?=(SELECT|INSERT|UPDATE|DELETE|CREATE|REPLACE|ALTER|AND|WITH)\\b)' + 'begin': '(?i)"(?=\\s*\\(?\\s*(SELECT|INSERT|UPDATE|DELETE|CREATE|REPLACE|ALTER|AND|WITH)\\b)' 'beginCaptures': '0': 'name': 'punctuation.definition.string.begin.php' @@ -2828,7 +2828,7 @@ } ] 'sql-string-single-quoted': - 'begin': '\'\\s*(?=(SELECT|INSERT|UPDATE|DELETE|CREATE|REPLACE|ALTER|AND|WITH)\\b)' + 'begin': '(?i)\'(?=\\s*\\(?\\s*(SELECT|INSERT|UPDATE|DELETE|CREATE|REPLACE|ALTER|AND|WITH)\\b)' 'beginCaptures': '0': 'name': 'punctuation.definition.string.begin.php' diff --git a/spec/php-spec.coffee b/spec/php-spec.coffee index 73e4c8e..2918218 100644 --- a/spec/php-spec.coffee +++ b/spec/php-spec.coffee @@ -2948,6 +2948,24 @@ describe 'PHP grammar', -> expect(tokens[2]).toEqual value: ' something', scopes: ['source.php', scope, 'source.sql.embedded.php'] expect(tokens[3]).toEqual value: delim, scopes: ['source.php', scope, 'punctuation.definition.string.end.php'] + {tokens} = grammar.tokenizeLine "#{delim}sEleCT something#{delim}" + + # Case insensitive + expect(tokens[0]).toEqual value: delim, scopes: ['source.php', scope, 'punctuation.definition.string.begin.php'] + expect(tokens[1]).toEqual value: 'sEleCT', scopes: ['source.php', scope, 'source.sql.embedded.php', 'keyword.other.DML.sql'] + expect(tokens[2]).toEqual value: ' something', scopes: ['source.php', scope, 'source.sql.embedded.php'] + expect(tokens[3]).toEqual value: delim, scopes: ['source.php', scope, 'punctuation.definition.string.end.php'] + + {tokens} = grammar.tokenizeLine "#{delim}(select something)#{delim}" + + # Surrounded by brackets + expect(tokens[0]).toEqual value: delim, scopes: ['source.php', scope, 'punctuation.definition.string.begin.php'] + expect(tokens[1]).toEqual value: '(', scopes: ['source.php', scope, 'source.sql.embedded.php', 'punctuation.definition.section.bracket.round.begin.sql'] + expect(tokens[2]).toEqual value: 'select', scopes: ['source.php', scope, 'source.sql.embedded.php', 'keyword.other.DML.sql'] + expect(tokens[3]).toEqual value: ' something', scopes: ['source.php', scope, 'source.sql.embedded.php'] + expect(tokens[4]).toEqual value: ')', scopes: ['source.php', scope, 'source.sql.embedded.php', 'punctuation.definition.section.bracket.round.end.sql'] + expect(tokens[5]).toEqual value: delim, scopes: ['source.php', scope, 'punctuation.definition.string.end.php'] + lines = grammar.tokenizeLines """ #{delim}SELECT something -- uh oh a comment SELECT#{delim}