ruby / reline

The compatible library with the API of Ruby's stdlib 'readline'
Other
260 stars 83 forks source link

nonprinting_start and nonprinting_end should be removed before print #771

Closed tompng closed 1 week ago

tompng commented 1 week ago

Fixes #770

Reline::Unicode.take_range("ABC\1[zero]\2DEFGHIJ", 0, 6)
# => "ABC\u0001[zero]\u0002DEF" (before)
# => "ABC[zero]DEF" (after)

Readline removes \1 and \2. Reline was doing the same until 0.3.2 but broken since 0.3.3

# Readline 8.2
PTY.spawn('ruby', '-e', %q(require 'readline'; Readline.readline "prompt\1[invis]\2>")){|r,w|p r.readpartial(1024)}
#=> "...prompt[invis]>..."

# Reline
PTY.spawn('ruby', '-e', %q(require 'reline'; Reline.readline "prompt\1[invis]\2>")){|r,w|20.times{p s=r.readpartial(1024);w.write "\e[1;1R" if s=~/\[6n/}}
#=> "...prompt\x01[invis]\x02>..." # \x01 and \x02 should be removed