mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[ruby/irb] Move require out of repeated execution path
SHOW_DOC_DIALOG will be called repeatedly whenever the corresponding key is pressed, but we only need to require rdoc once. So ideally the require can be put outside of the proc. And because when rdoc is not available the entire proc will be nonfunctional, we can stop registering the SHOW_DOC_DIALOG if we failed to require rdoc. https://github.com/ruby/irb/commit/b1278b7320
This commit is contained in:
parent
d377cc4530
commit
b7622d792d
1 changed files with 6 additions and 6 deletions
|
@ -296,8 +296,13 @@ module IRB
|
|||
end
|
||||
Reline.dig_perfect_match_proc = IRB::InputCompletor::PerfectMatchedProc
|
||||
Reline.autocompletion = IRB.conf[:USE_AUTOCOMPLETE]
|
||||
|
||||
if IRB.conf[:USE_AUTOCOMPLETE]
|
||||
Reline.add_dialog_proc(:show_doc, SHOW_DOC_DIALOG, Reline::DEFAULT_DIALOG_CONTEXT)
|
||||
begin
|
||||
require 'rdoc'
|
||||
Reline.add_dialog_proc(:show_doc, SHOW_DOC_DIALOG, Reline::DEFAULT_DIALOG_CONTEXT)
|
||||
rescue LoadError
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -321,11 +326,6 @@ module IRB
|
|||
[195, 164], # The "ä" that appears when Alt+d is pressed on xterm.
|
||||
[226, 136, 130] # The "∂" that appears when Alt+d in pressed on iTerm2.
|
||||
]
|
||||
begin
|
||||
require 'rdoc'
|
||||
rescue LoadError
|
||||
return nil
|
||||
end
|
||||
|
||||
if just_cursor_moving and completion_journey_data.nil?
|
||||
return nil
|
||||
|
|
Loading…
Reference in a new issue