Prevent additional single-line if indentations [Fixes #1325]

This commit is contained in:
Keegan Lowenstein 2014-12-04 00:56:37 -08:00
parent 4fe3d3b90a
commit 2404d68345
2 changed files with 7 additions and 2 deletions

View File

@ -66,8 +66,10 @@ class Pry
#
# :reserved and :keywords are the CodeRay 0.9.8 and 1.0.0 respectively
# classifications of "super", "next", "return", etc.
STATEMENT_END_TOKENS = IGNORE_TOKENS + [:regexp, :integer, :float, :keyword,
:delimiter, :reserved]
STATEMENT_END_TOKENS = IGNORE_TOKENS + [:regexp, :integer, :float,
:keyword, :delimiter, :reserved,
:instance_variable,
:class_variable, :global_variable]
# Collection of tokens that should appear dedented even though they
# don't affect the surrounding code.

View File

@ -200,6 +200,9 @@ TXT
@indent.reset.indent("foo() if bar\n#").should == "foo() if bar\n#"
@indent.reset.indent("foo 'hi' if bar\n#").should == "foo 'hi' if bar\n#"
@indent.reset.indent("foo 1 while bar\n#").should == "foo 1 while bar\n#"
@indent.reset.indent("$foo if false\n#").should == "$foo if false\n#"
@indent.reset.indent("@foo if false\n#").should == "@foo if false\n#"
@indent.reset.indent("@@foo if false\n#").should == "@@foo if false\n#"
@indent.reset.indent("super if true\n#").should == "super if true\n#"
@indent.reset.indent("true if false\n#").should == "true if false\n#"
@indent.reset.indent("String if false\n#").should == "String if false\n#"