From 2404d68345786fba76fb80ffc06b021e6b4a7c51 Mon Sep 17 00:00:00 2001 From: Keegan Lowenstein Date: Thu, 4 Dec 2014 00:56:37 -0800 Subject: [PATCH] Prevent additional single-line if indentations [Fixes #1325] --- lib/pry/indent.rb | 6 ++++-- spec/indent_spec.rb | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/pry/indent.rb b/lib/pry/indent.rb index 72fbf69b..fc33ec07 100644 --- a/lib/pry/indent.rb +++ b/lib/pry/indent.rb @@ -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. diff --git a/spec/indent_spec.rb b/spec/indent_spec.rb index 025417b7..cc05405d 100644 --- a/spec/indent_spec.rb +++ b/spec/indent_spec.rb @@ -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#"