[ruby/reline] Input with eof and no newline bugfix
(https://github.com/ruby/reline/pull/671) https://github.com/ruby/reline/commit/0d66c335a1
This commit is contained in:
parent
4c41203bbb
commit
814d4b5e2c
@ -284,7 +284,7 @@ class Reline::ANSI
|
||||
buf = @@output.pread(@@output.pos, 0)
|
||||
row = buf.count("\n")
|
||||
column = buf.rindex("\n") ? (buf.size - buf.rindex("\n")) - 1 : 0
|
||||
rescue Errno::ESPIPE
|
||||
rescue Errno::ESPIPE, IOError
|
||||
# Just returns column 1 for ambiguous width because this I/O is not
|
||||
# tty and can't seek.
|
||||
row = 0
|
||||
|
@ -1118,6 +1118,7 @@ class Reline::LineEditor
|
||||
end
|
||||
end
|
||||
if key.char.nil?
|
||||
process_insert(force: true)
|
||||
if @first_char
|
||||
@eof = true
|
||||
end
|
||||
|
@ -945,18 +945,30 @@ begin
|
||||
EOC
|
||||
end
|
||||
|
||||
def test_with_newline
|
||||
def test_eof_with_newline
|
||||
omit if Reline.core.io_gate.win?
|
||||
cmd = %Q{ruby -e 'print(%Q{abc def \\e\\r})' | ruby -I#{@pwd}/lib -rreline -e 'p Reline.readline(%{> })'}
|
||||
start_terminal(40, 50, ['bash', '-c', cmd])
|
||||
sleep 1
|
||||
close
|
||||
close rescue nil
|
||||
assert_screen(<<~'EOC')
|
||||
> abc def
|
||||
"abc def "
|
||||
EOC
|
||||
end
|
||||
|
||||
def test_eof_without_newline
|
||||
omit if Reline.core.io_gate.win?
|
||||
cmd = %Q{ruby -e 'print(%{hello})' | ruby -I#{@pwd}/lib -rreline -e 'p Reline.readline(%{> })'}
|
||||
start_terminal(40, 50, ['bash', '-c', cmd])
|
||||
sleep 1
|
||||
close rescue nil
|
||||
assert_screen(<<~'EOC')
|
||||
> hello
|
||||
"hello"
|
||||
EOC
|
||||
end
|
||||
|
||||
def test_em_set_mark_and_em_exchange_mark
|
||||
start_terminal(10, 50, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.')
|
||||
write("aaa bbb ccc ddd\M-b\M-b\M-\x20\M-b\C-x\C-xX\C-x\C-xY")
|
||||
|
Loading…
x
Reference in New Issue
Block a user