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

[ruby/reline] Use default dialog context to communicate others

https://github.com/ruby/reline/commit/5e67e6ffe0
This commit is contained in:
aycabta 2021-08-29 19:27:04 +09:00
parent b023ef8594
commit 29586ec9f3

View file

@ -209,10 +209,13 @@ module Reline
y = 0
end
cursor_pos_to_render = Reline::CursorPos.new(x, y)
if context and context.is_a?(Array)
context.clear
context.push(cursor_pos_to_render, result, pointer)
end
[cursor_pos_to_render, result, pointer, nil]
}
DEFAULT_DIALOG_CONTEXT = Array.new
require 'rdoc'
SHOW_DOC_DIALOG = ->() {
@ -255,8 +258,8 @@ module Reline
raise ArgumentError.new('#readmultiline needs block to confirm multiline termination')
end
context = []
add_dialog_proc(:autocomplete, DEFAULT_DIALOG_PROC_AUTOCOMPLETE, context)
add_dialog_proc(:show_doc, SHOW_DOC_DIALOG, context)
add_dialog_proc(:autocomplete, DEFAULT_DIALOG_PROC_AUTOCOMPLETE, DEFAULT_DIALOG_CONTEXT)
add_dialog_proc(:show_doc, SHOW_DOC_DIALOG, DEFAULT_DIALOG_CONTEXT)
inner_readline(prompt, add_hist, true, &confirm_multiline_termination)
whole_buffer = line_editor.whole_buffer.dup