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:
commit
e5756706d0
2 changed files with 16 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue