1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[ruby/reline] Escape newline(s) in prompt

b545459fca
This commit is contained in:
aycabta 2021-12-24 20:06:48 +09:00 committed by git
parent 22cc2243f9
commit b0db420b0e
2 changed files with 14 additions and 1 deletions

View file

@ -260,7 +260,7 @@ class Reline::LineEditor
end
def reset_variables(prompt = '', encoding:)
@prompt = prompt
@prompt = prompt.gsub("\n", "\\n")
@mark_pointer = nil
@encoding = encoding
@is_multiline = false

View file

@ -1228,6 +1228,19 @@ begin
EOC
end
def test_prompt_with_newline
ENV['RELINE_TEST_PROMPT'] = "::\n> "
start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.')
write("def hoge\n 3\nend")
close
assert_screen(<<~'EOC')
Multiline REPL.
::\n> def hoge
::\n> 3
::\n> end
EOC
end
def write_inputrc(content)
File.open(@inputrc_file, 'w') do |f|
f.write content