summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authoraycabta <aycabta@gmail.com>2021-09-03 01:17:10 +0900
committergit <svn-admin@ruby-lang.org>2021-09-03 04:28:27 +0900
commitf793f682641030da81a45f5a9a0f3191f79a75c2 (patch)
tree45e0ae1c9db0b422331d72b66418c7d7fed610d8 /lib
parent057ab5f056bb310e324a48ca0aed2ee5231bcbd2 (diff)
[ruby/irb] Add Alt+d trap from show doc dialog to show full doc
https://github.com/ruby/irb/commit/368327b082
Diffstat (limited to 'lib')
-rw-r--r--lib/irb/input-method.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/irb/input-method.rb b/lib/irb/input-method.rb
index 953916308e..915c8fd075 100644
--- a/lib/irb/input-method.rb
+++ b/lib/irb/input-method.rb
@@ -314,11 +314,14 @@ module IRB
end
SHOW_DOC_DIALOG = ->() {
+ dialog.trap_key = nil
+ alt_d = 0xE4
begin
require 'rdoc'
rescue LoadError
return nil
end
+
if just_cursor_moving and completion_journey_data.nil?
return nil
end
@@ -328,6 +331,14 @@ module IRB
name = IRB::InputCompletor.retrieve_completion_data(name, doc_namespace: true)
driver = RDoc::RI::Driver.new
+
+ if key.combined_char == alt_d
+ begin
+ driver.display_names([name])
+ rescue RDoc::RI::Driver::NotFoundError
+ end
+ end
+
begin
name = driver.expand_name(name)
rescue RDoc::RI::Driver::NotFoundError
@@ -358,6 +369,7 @@ module IRB
width = 40
formatter = RDoc::Markup::ToAnsi.new
formatter.width = width
+ dialog.trap_key = alt_d
contents = doc.accept(formatter).split("\n")
x = cursor_pos_to_render.x + autocomplete_dialog.width