From 29586ec9f3836afbfd9a48c30782fd178045e0c3 Mon Sep 17 00:00:00 2001 From: aycabta Date: Sun, 29 Aug 2021 19:27:04 +0900 Subject: [PATCH] [ruby/reline] Use default dialog context to communicate others https://github.com/ruby/reline/commit/5e67e6ffe0 --- lib/reline.rb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/reline.rb b/lib/reline.rb index cb51738958..0ff4c31040 100644 --- a/lib/reline.rb +++ b/lib/reline.rb @@ -209,10 +209,13 @@ module Reline y = 0 end cursor_pos_to_render = Reline::CursorPos.new(x, y) - context.clear - context.push(cursor_pos_to_render, result, pointer) + 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