Skip to content

Commit

Permalink
Increase the source level for strings and regexps.
Browse files Browse the repository at this point in the history
  • Loading branch information
alloy committed Aug 6, 2010
1 parent 020111a commit 3fe8374
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
30 changes: 30 additions & 0 deletions lib/irb/source.rb
Expand Up @@ -183,6 +183,36 @@ def on_rbrace(token) #:nodoc:
@level -= 1
super
end

def on_tstring_beg(token)
@level += 1
super
end

def on_tstring_end(token)
@level -= 1
super
end

def on_qwords_beg(token)
@level += 1
super
end

def on_words_sep(token)
@level -= 1
super
end

def on_regexp_beg(token)
@level += 1
super
end

def on_regexp_end(token)
@level -= 1
super
end
end
end
end
9 changes: 7 additions & 2 deletions spec/source_spec.rb
Expand Up @@ -186,8 +186,13 @@ def reflect(source)
[
["lambda { |x|", "}"],
["{", "}"],
['"#{', '}"'],
["[", "]"]
["[", "]"],
["'", "'"],
['"', '"'],
["%{", "}"],
["%w{", "}"],
["%r{", "}"],
["/", "/"]
].each do |open, close|
reflect(open).level.should == 1
reflect("#{open}\n#{close}").level.should == 0
Expand Down

0 comments on commit 3fe8374

Please sign in to comment.