mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-20 23:48:05 +03:00
Mock getMaxTokensPerLine instead of overwriting member var
This commit is contained in:
parent
a9175665fa
commit
7d9e64a52d
@ -302,7 +302,7 @@ describe "TextMateGrammar", ->
|
||||
describe "when a line has more tokens than `maxTokensPerLine`", ->
|
||||
it "creates a final token with the remaining text and resets the ruleStack to match the begining of the line", ->
|
||||
grammar = syntax.selectGrammar("hello.js")
|
||||
grammar.maxTokensPerLine = 5
|
||||
spyOn(grammar, 'getMaxTokensPerLine').andCallFake -> 5
|
||||
originalRuleStack = [grammar.initialRule, grammar.initialRule, grammar.initialRule]
|
||||
{tokens, ruleStack} = grammar.tokenizeLine("one(two(three(four(five(_param_)))))", originalRuleStack)
|
||||
expect(tokens.length).toBe 5
|
||||
|
@ -48,7 +48,7 @@ class TextMateGrammar
|
||||
previousRuleStackLength = ruleStack.length
|
||||
previousPosition = position
|
||||
|
||||
if tokens.length >= (@maxTokensPerLine - 1)
|
||||
if tokens.length >= (@getMaxTokensPerLine() - 1)
|
||||
token = new Token(value: line[position..], scopes: scopes)
|
||||
tokens.push token
|
||||
ruleStack = originalRuleStack
|
||||
@ -87,6 +87,9 @@ class TextMateGrammar
|
||||
ruleStack.forEach (rule) -> rule.clearAnchorPosition()
|
||||
{ tokens, ruleStack }
|
||||
|
||||
getMaxTokensPerLine: ->
|
||||
@maxTokensPerLine
|
||||
|
||||
class Rule
|
||||
grammar: null
|
||||
scopeName: null
|
||||
|
Loading…
Reference in New Issue
Block a user