From d0f198bd649baddcea739620f1e7901eb0894ea0 Mon Sep 17 00:00:00 2001 From: Ryan Fitzgerald Date: Sat, 2 Nov 2013 15:46:38 -0700 Subject: [PATCH] Fix a couple of SimplePager bugs * Exiting with q was broken by d703320e38397c1b3bf9cb3fc4389f9c741c448b. * We were only removing color codes in the case where the input string ends with a newline, which means we were overestimating the length of strings that don't end with newlines. After fixing that, SimplePager can accurately page through the inspect output for _pry_. --- lib/pry/color_printer.rb | 4 +++- lib/pry/pager.rb | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/pry/color_printer.rb b/lib/pry/color_printer.rb index e0852b28..f7c33e95 100644 --- a/lib/pry/color_printer.rb +++ b/lib/pry/color_printer.rb @@ -32,7 +32,9 @@ class Pry def pp(obj) super - rescue + rescue => e + raise if e.is_a? Pry::Pager::StopPaging + # Read the class name off of the singleton class to provide a default # inspect. eig = class << obj; self; end diff --git a/lib/pry/pager.rb b/lib/pry/pager.rb index 85c74776..a5239b37 100644 --- a/lib/pry/pager.rb +++ b/lib/pry/pager.rb @@ -181,7 +181,7 @@ class Pry::Pager @row += ((@col + line_length(line) - 1) / @cols) + 1 @col = 0 else - @col += line.length + @col += line_length(line) end end end