mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
parent
b0db420b0e
commit
c815c0be46
3 changed files with 21 additions and 1 deletions
|
@ -121,7 +121,7 @@ class Reline::LineEditor
|
||||||
if use_cached_prompt_list
|
if use_cached_prompt_list
|
||||||
prompt_list = @cached_prompt_list
|
prompt_list = @cached_prompt_list
|
||||||
else
|
else
|
||||||
prompt_list = @cached_prompt_list = @prompt_proc.(buffer)
|
prompt_list = @cached_prompt_list = @prompt_proc.(buffer).map { |pr| pr.gsub("\n", "\\n") }
|
||||||
@prompt_cache_time = Time.now.to_f
|
@prompt_cache_time = Time.now.to_f
|
||||||
end
|
end
|
||||||
prompt_list.map!{ prompt } if @vi_arg or @searching_prompt
|
prompt_list.map!{ prompt } if @vi_arg or @searching_prompt
|
||||||
|
|
|
@ -27,6 +27,14 @@ opt.on('--broken-dynamic-prompt') {
|
||||||
opt.on('--dynamic-prompt-returns-empty') {
|
opt.on('--dynamic-prompt-returns-empty') {
|
||||||
Reline.prompt_proc = proc { |l| [] }
|
Reline.prompt_proc = proc { |l| [] }
|
||||||
}
|
}
|
||||||
|
opt.on('--dynamic-prompt-with-newline') {
|
||||||
|
Reline.prompt_proc = proc { |lines|
|
||||||
|
range = lines.size > 1 ? (0..(lines.size - 2)) : (0..0)
|
||||||
|
lines[range].each_with_index.map { |l, i|
|
||||||
|
'[%04d\n]> ' % i
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
opt.on('--auto-indent') {
|
opt.on('--auto-indent') {
|
||||||
AutoIndent.new
|
AutoIndent.new
|
||||||
}
|
}
|
||||||
|
|
|
@ -1241,6 +1241,18 @@ begin
|
||||||
EOC
|
EOC
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_dynamic_prompt_with_newline
|
||||||
|
start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --dynamic-prompt-with-newline}, startup_message: 'Multiline REPL.')
|
||||||
|
write("def hoge\n 3\nend")
|
||||||
|
close
|
||||||
|
assert_screen(<<~'EOC')
|
||||||
|
Multiline REPL.
|
||||||
|
[0000\n]> def hoge
|
||||||
|
[0001\n]> 3
|
||||||
|
[0001\n]> end
|
||||||
|
EOC
|
||||||
|
end
|
||||||
|
|
||||||
def write_inputrc(content)
|
def write_inputrc(content)
|
||||||
File.open(@inputrc_file, 'w') do |f|
|
File.open(@inputrc_file, 'w') do |f|
|
||||||
f.write content
|
f.write content
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue