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

Merge pull request #1771 from DamienRobert/fix_indent

repl.rb: guard against negative overhang
This commit is contained in:
Kyrylo Silin 2018-10-04 21:25:21 +08:00 committed by GitHub
commit e5756706d0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View file

@ -107,7 +107,7 @@ class Pry
if output.tty? && pry.config.correct_indent && Pry::Helpers::BaseHelpers.use_ansi_codes?
output.print @indent.correct_indentation(
current_prompt, indented_val,
original_val.length - indented_val.length
[ original_val.length - indented_val.length, 0 ].max
)
output.flush
end

View file

@ -121,4 +121,19 @@ describe Pry::REPL do
$stdout = old_stdout
end
end
describe "autoindent" do
it "should raise no exception when indented with a tab" do
ReplTester.start(correct_indent: true, auto_indent: true) do
output=@pry.config.output
def output.tty?; true; end
input <<EOS
loop do
break #note the tab here
end
EOS
output("do\n break #note the tab here\nend\n\e[1B\e[0G=> nil")
end
end
end
end