summaryrefslogtreecommitdiff
path: root/lib/irb/completion.rb
diff options
context:
space:
mode:
authoraycabta <aycabta@gmail.com>2019-04-23 18:09:46 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-04-23 20:08:02 +0900
commitf2cd4f4cd0a1e352fcc48a216127beaeda2b2399 (patch)
tree8e02f39a8df8fa5708e446aeb8d42d45d8a28abe /lib/irb/completion.rb
parent87cf45a512a7803f266e4782c49e0a99c06a4039 (diff)
IRB is improved with Reline and RDoc, take 2
Diffstat (limited to 'lib/irb/completion.rb')
-rw-r--r--lib/irb/completion.rb19
1 files changed, 11 insertions, 8 deletions
diff --git a/lib/irb/completion.rb b/lib/irb/completion.rb
index 390e7254dd..4cd9427743 100644
--- a/lib/irb/completion.rb
+++ b/lib/irb/completion.rb
@@ -8,11 +8,10 @@
#
require "readline"
+require "rdoc"
module IRB
module InputCompletor # :nodoc:
-
-
# Set of reserved words used by Ruby, you should not use these for
# constants or variables
ReservedWords = %w[
@@ -35,6 +34,8 @@ module IRB
yield
]
+ BASIC_WORD_BREAK_CHARACTERS = " \t\n`><=;|&{("
+
CompletionProc = proc { |input|
bind = IRB.conf[:MAIN_CONTEXT].workspace.binding
@@ -195,6 +196,14 @@ module IRB
end
}
+ RDocRIDriver = RDoc::RI::Driver.new
+ PerfectMatchedProc = proc { |matched|
+ begin
+ RDocRIDriver.display_name(matched)
+ rescue RDoc::RI::Driver::NotFoundError
+ end
+ }
+
# Set of available operators in Ruby
Operators = %w[% & * ** + - / < << <= <=> == === =~ > >= >> [] []= ^ ! != !~]
@@ -236,9 +245,3 @@ module IRB
end
end
end
-
-if Readline.respond_to?("basic_word_break_characters=")
- Readline.basic_word_break_characters= " \t\n`><=;|&{("
-end
-Readline.completion_append_character = nil
-Readline.completion_proc = IRB::InputCompletor::CompletionProc