aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorst0012 <stan001212@gmail.com>2022-10-18 10:08:24 +0100
committergit <svn-admin@ruby-lang.org>2022-10-24 13:36:57 +0000
commitb7622d792dde7922692de6fcf43bd87cd7faa97b (patch)
tree8df5291807efb02c1dedb5ae8dfc5e716e6c198b /lib
parentd377cc4530c1edeb4281a6a5a7ee2a4d13b1b561 (diff)
downloadruby-b7622d792dde7922692de6fcf43bd87cd7faa97b.tar.gz
[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
Diffstat (limited to 'lib')
-rw-r--r--lib/irb/input-method.rb12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/irb/input-method.rb b/lib/irb/input-method.rb
index b0110dd09b..5f13971a43 100644
--- a/lib/irb/input-method.rb
+++ b/lib/irb/input-method.rb
@@ -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