fixing parens-around-implicit-function-with-multiline-chained-chaser bug

This commit is contained in:
Jeremy Ashkenas
2010-04-01 23:38:20 -04:00
parent 3605168e85
commit 1c628e7883
3 changed files with 16 additions and 3 deletions

View File

@@ -111,6 +111,7 @@ exports.Rewriter: class Rewriter
stack: [0]
calls: 0
parens: 0
start_parens: 0
@scan_tokens (prev, token, post, i) =>
tag: token[0]
switch tag
@@ -123,7 +124,7 @@ exports.Rewriter: class Rewriter
last: stack.pop()
stack[stack.length - 1]: + last
open: stack[stack.length - 1] > 0
if !post? or (parens is 0 and include IMPLICIT_END, tag)
if !post? or (start_parens > parens) or (parens is 0 and include IMPLICIT_END, tag)
return 1 if tag is 'INDENT' and prev and include IMPLICIT_BLOCK, prev[0]
return 1 if tag is 'OUTDENT' and token.generated
if open or tag is 'INDENT'
@@ -136,6 +137,7 @@ exports.Rewriter: class Rewriter
return size
return 1 unless prev and include(IMPLICIT_FUNC, prev[0]) and include(IMPLICIT_CALL, tag)
calls: 0
start_parens: if tag is '(' then parens - 1 else parens
@tokens.splice i, 0, ['CALL_START', '(', token[2]]
stack[stack.length - 1]: + 1
return 2