mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[ruby/reline] Work with wrong $/ value correctly
https://github.com/ruby/reline/commit/962ebf5a1b
This commit is contained in:
parent
22477128cd
commit
f245fb1ab8
3 changed files with 13 additions and 4 deletions
|
@ -175,7 +175,7 @@ module Reline
|
|||
|
||||
whole_buffer = line_editor.whole_buffer.dup
|
||||
whole_buffer.taint if RUBY_VERSION < '2.7'
|
||||
if add_hist and whole_buffer and whole_buffer.chomp.size > 0
|
||||
if add_hist and whole_buffer and whole_buffer.chomp("\n").size > 0
|
||||
Reline::HISTORY << whole_buffer
|
||||
end
|
||||
|
||||
|
@ -188,8 +188,8 @@ module Reline
|
|||
|
||||
line = line_editor.line.dup
|
||||
line.taint if RUBY_VERSION < '2.7'
|
||||
if add_hist and line and line.chomp.size > 0
|
||||
Reline::HISTORY << line.chomp
|
||||
if add_hist and line and line.chomp("\n").size > 0
|
||||
Reline::HISTORY << line.chomp("\n")
|
||||
end
|
||||
|
||||
line_editor.reset_line if line_editor.line.nil?
|
||||
|
|
|
@ -543,7 +543,7 @@ class Reline::LineEditor
|
|||
return before if before.nil? || before.empty?
|
||||
|
||||
if after = @output_modifier_proc&.call("#{before.join("\n")}\n", complete: finished?)
|
||||
after.lines(chomp: true)
|
||||
after.lines("\n", chomp: true)
|
||||
else
|
||||
before
|
||||
end
|
||||
|
|
|
@ -1896,6 +1896,15 @@ class Reline::KeyActor::Emacs::Test < Reline::TestCase
|
|||
assert_equal([0, 0], @line_editor.instance_variable_get(:@mark_pointer))
|
||||
end
|
||||
|
||||
def test_modify_lines_with_wrong_rs
|
||||
original_global_slash = $/
|
||||
$/ = 'b'
|
||||
@line_editor.output_modifier_proc = proc { |output| Reline::Unicode.escape_for_print(output) }
|
||||
input_keys("abcdef\n")
|
||||
assert_equal(['abcdef'], @line_editor.__send__(:modify_lines, @line_editor.whole_lines))
|
||||
$/ = original_global_slash
|
||||
end
|
||||
|
||||
=begin # TODO: move KeyStroke instance from Reline to LineEditor
|
||||
def test_key_delete
|
||||
input_keys('ab')
|
||||
|
|
Loading…
Reference in a new issue