begin = '(^[ \t]+)?(?=//)';
end = '(?!\G)';
beginCaptures = { 1 = { name = 'punctuation.whitespace.comment.leading.js'; }; };
patterns = (
{ name = 'comment.line.double-slash.js';
begin = '//';
end = '\n';
beginCaptures = { 0 = { name = 'punctuation.definition.comment.js'; }; };
},
);
Since TextMate grammars are line based, I'm not sure how it's possible for the '\n' pattern and the '(?!\G)' pattern to work together. For example, take these two lines:
// a comment
var foo
The 'single line comment' rule is entered by matching it's begin pattern '(^[ \t]+)?(?=//)'. The 'comment.line.double-slash.js'' rule is then entered upon matching '//', the rule is ended when '\n' is matched. Because we have matched the end of the first line, we continue to the second line. The second line will end the 'single line comment' rule because the end pattern '(?!\G)' will match the 'a' in 'var'. Because of this, var cannot be scooped correctly because the 'v' is considered to be part of the 'single line comment' rule.
This fails as I described in TextMate 1 but works in TextMate 2. Is there something fundamentally different about using the \G anchor in TextMate 2.
Thanks,
Corey