special case for 'else if' in the lexer

This commit is contained in:
Jeremy Ashkenas
2009-12-30 17:41:14 -05:00
parent 9a946d2ac5
commit d528db76e6

View File

@@ -255,7 +255,8 @@ module CoffeeScript
# blocks, so it doesn't need to.
def add_implicit_indentation
scan_tokens do |prev, token, post, i|
if SINGLE_LINERS.include?(token[0]) && post[0] != :INDENT
if SINGLE_LINERS.include?(token[0]) && post[0] != :INDENT &&
!(token[0] == :ELSE && post[0] == :IF) # Elsifs shouldn't get blocks.
line = token[1].line
@tokens.insert(i + 1, [:INDENT, Value.new(2, line)])
idx = i + 1