From: Heesob Park Date: 2010-11-08T10:19:26+09:00 Subject: Re: irb misbehaviour with arrow keys on Windows Hi, 2010/11/7 Marvin Gülker : > Hi there, > > It seems that irb has problems with the arrow keys on Windows. Steps to > reproduce: > > 1. Start up CMD. > 2. Type "irb" and press return > 3. Type "abc" and *do not* press return > 4. Press the right arrow key > 5. Now try typing "defg" - the characters don't show up anymore. If you > press return followed by the up arrow key, the whole sequence you typed, > including the mysteriously invisible characters, shows up. > > I'm using ruby 1.9.2p0 (2010-08-18) [i386-mingw32] on Windows Vista > 32-bit, installed by extracting the 7z archive provided by the > RubyInstaller team to C:\Rubies\ruby-1.9.2-p0-i386-mingw32. Of course I > added the bin\ subdirectory to my PATH variable. > I don't know wheather in matters, but I don't have the RubyInstaller's > devkit installed, but a separate MinGW+MSYS installation in C:\MinGW > which is up-to-date. > > Anyone experiencing the same problem? > This is a bug of rbreadline. Here is a patch for rbrealine.rb --- rbreadline.rb 2010-11-08 10:10:28.000000000 +0900 +++ rbreadline.rb.new 2010-11-08 10:10:11.000000000 +0900 @@ -8435,21 +8435,20 @@ count -= 1 end + str = (flags == MB_FIND_NONZERO) ? string.strip : string + case @encoding when 'E' - point += string[point..-1].scan(/./me)[0,count].to_s.length + point += str[point..-1].scan(/./me)[0,count].to_s.length when 'S' - point += string[point..-1].scan(/./ms)[0,count].to_s.length + point += str[point..-1].scan(/./ms)[0,count].to_s.length when 'U' - point += string[point..-1].scan(/./mu)[0,count].to_s.length + point += str[point..-1].scan(/./mu)[0,count].to_s.length when 'X' - point += string[point..-1].force_encoding(@encoding_name)[0,count].byt + point += str[point..-1].force_encoding(@encoding_name)[0,count].bytesi else point += count end - if flags == MB_FIND_NONZERO - point = string.length if point>=string.length - end point end Regards, Park Heesob