From 5c4e14bafc8668885604c5bc19cf370b4c328298 Mon Sep 17 00:00:00 2001 From: Brian Graham Date: Fri, 6 Dec 2019 16:42:27 -0500 Subject: [PATCH] indent: handle consecutive linebreaks --- lib/pry/indent.rb | 4 ++-- spec/indent_spec.rb | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/lib/pry/indent.rb b/lib/pry/indent.rb index 963758a6f..867e72914 100644 --- a/lib/pry/indent.rb +++ b/lib/pry/indent.rb @@ -162,14 +162,14 @@ def indent(input) line = prefix + line.lstrip unless previously_in_string - output += line + output += "#{line.chomp}\n" prefix = new_prefix end @indent_level = prefix - output + output.chomp end # Get the indentation for the start of the next line. diff --git a/spec/indent_spec.rb b/spec/indent_spec.rb index 29c07a5f1..14af948f4 100644 --- a/spec/indent_spec.rb +++ b/spec/indent_spec.rb @@ -102,6 +102,34 @@ def number expect(@indent.indent(input)).to eq output end + it 'should properly indent nested code with consecutive linebreaks' do + input = <