Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Weird bug navigating multiline command history in pry

Tags:

ruby

pry

When I enter a string that is too long for the console width into a pry or regular irb console it wraps as usual, see below (Using pry in OS X 10.8.2 terminal.app):

pry - entering ok

However when I try to replay the command using the up arrow I get this: enter image description here Pry cuts off some of the command and repeats the prompt. Irb on the other hand behaves just fine, even scrolling up the buffer if needed: irb - ok replay

like image 439
David Avatar asked Oct 21 '22 23:10

David


2 Answers

Kyrylo: We have that fixed in the master branch if you Pry.auto_resize!

But the problem here is (as ryanf points out on Freenode #pry), is that the prompt has color escapes in it.

\e[XXn takes up no spaces, but counts as 5 bytes, so Readline gets confused.

Does anyone know of any Ruby use of Readline that doesn't have this problem?

like image 196
rking Avatar answered Oct 24 '22 15:10

rking


It looks like you resized your terminal window after you entered the first expression. For the time being, Pry doesn't really take into account this event and treats window size as a constant value. Unfortunately, the only solution is to relaunch Pry every time you need to resize your window. This is a bug and sooner or later it will be fixed.

like image 20
kyrylo Avatar answered Oct 24 '22 17:10

kyrylo