mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-22 08:28:41 +03:00
Terminate when tokens end position is undefined
This ensures the position is advanced for zero-length matches and only terminates when the end position for the tokens is no longer valid.
This commit is contained in:
parent
d37a0dd916
commit
4ccaa6f714
@ -41,20 +41,21 @@ class TextMateGrammar
|
||||
|
||||
{ nextTokens, tokensStartPosition, tokensEndPosition} = _.last(stack).getNextTokens(stack, line, position)
|
||||
|
||||
if nextTokens
|
||||
if position < tokensStartPosition # unmatched text preceding next tokens
|
||||
tokens.push
|
||||
value: line[position...tokensStartPosition]
|
||||
scopes: scopes
|
||||
if position < tokensStartPosition # unmatched text before next tokens
|
||||
tokens.push
|
||||
value: line[position...tokensStartPosition]
|
||||
scopes: scopes
|
||||
|
||||
tokens.push(nextTokens...)
|
||||
position = tokensEndPosition
|
||||
else if tokensEndPosition - tokensStartPosition != 0 # break unless it was a zero length match
|
||||
tokens.push(nextTokens...) if nextTokens
|
||||
|
||||
if tokensEndPosition is undefined # unmatched text after last token
|
||||
tokens.push
|
||||
value: line[position...line.length]
|
||||
scopes: scopes
|
||||
break
|
||||
|
||||
position = tokensEndPosition
|
||||
|
||||
{ tokens, stack }
|
||||
|
||||
ruleForInclude: (name) ->
|
||||
|
Loading…
Reference in New Issue
Block a user