1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

Always edit a blank file with -t

This commit is contained in:
Conrad Irwin 2011-09-13 18:56:10 -07:00
parent 75fb33e1c1
commit 4db25f1b8d
2 changed files with 11 additions and 4 deletions

View file

@ -139,11 +139,13 @@ class Pry
# edit of local code, eval'd within pry.
if !opts.ex? && args.empty?
content = if !eval_string.empty?
content = if opts.t?
""
elsif eval_string.strip != ""
eval_string
elsif !opts.t?
_pry_.input_array.reverse_each.find{ |x| x && x.strip != "" } # No present? in 1.8
end || ""
else
_pry_.input_array.reverse_each.find{ |x| x && x.strip != "" } || ""
end
line = content.lines.count

View file

@ -187,6 +187,11 @@ describe "Pry::DefaultCommands::Introspection" do
@contents.should == "\n"
end
it "should use a blank file if -t is specified even half-way through an expression" do
mock_pry("def a;", "edit -t")
@contents.should == "\n"
end
it "should position the cursor at the end of the expression" do
mock_pry("def a; 2;"," end", "edit")
@line.should == 2