mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Terminal: don't let Readline return [0, 0]
Some of the tests from "spec/commands/ls_spec.rb" were failing on
Rubinius and 1.9.2. The problems was introduced by this commit:
(Tweak and Refactor Pry::Terminal)
fc522f837a
The problem is that `Readline.get_screen_size` can return `[0, 0]`.
That's not good, because it breaks a couple of our tests (table output
stuff). But now...
.o( ...it is fixed. Twit-twoo! )
\{0,0}/
This commit is contained in:
parent
3760668d02
commit
d331ded410
1 changed files with 12 additions and 3 deletions
|
@ -44,11 +44,14 @@ class Pry::Terminal
|
|||
|
||||
def screen_size_according_to_env
|
||||
size = [ENV['LINES'] || ENV['ROWS'], ENV['COLUMNS']]
|
||||
size if size[1].to_i > 0
|
||||
size if nonzero_column?(size)
|
||||
end
|
||||
|
||||
def screen_size_according_to_readline
|
||||
Readline.get_screen_size if Readline.respond_to?(:get_screen_size)
|
||||
if Readline.respond_to?(:get_screen_size)
|
||||
size = Readline.get_screen_size
|
||||
size if nonzero_column?(size)
|
||||
end
|
||||
rescue Java::JavaLang::NullPointerException
|
||||
# This rescue won't happen on jrubies later than:
|
||||
# https://github.com/jruby/jruby/pull/436
|
||||
|
@ -58,7 +61,13 @@ class Pry::Terminal
|
|||
def screen_size_according_to_ansicon_env
|
||||
return unless ENV['ANSICON'] =~ /\((.*)x(.*)\)/
|
||||
size = [$2, $1]
|
||||
size if size[1].to_i > 0
|
||||
size if nonzero_column?(size)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def nonzero_column?(size)
|
||||
size[1].to_i > 0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue