From 7ad3ec757da9f9dd1c801f9b684b01e59d77b802 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 | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 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..489dc7789 100644 --- a/spec/indent_spec.rb +++ b/spec/indent_spec.rb @@ -102,6 +102,36 @@ def number expect(@indent.indent(input)).to eq output end + it 'should properly indent nested code with consecutive linebreaks' do + input = <