Skip to content

Commit b39c83e

Browse files
committed
Add completion info to irb_info
1 parent 678a6ed commit b39c83e

File tree

4 files changed

+19
-0
lines changed

4 files changed

+19
-0
lines changed

lib/irb/cmd/irb_info.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ def execute
1414
str = "Ruby version: #{RUBY_VERSION}\n"
1515
str += "IRB version: #{IRB.version}\n"
1616
str += "InputMethod: #{IRB.CurrentContext.io.inspect}\n"
17+
str += "Completion: #{IRB.CurrentContext.io.respond_to?(:completion_info) ? IRB.CurrentContext.io.completion_info : 'off'}\n"
1718
str += ".irbrc path: #{IRB.rc_file}\n" if File.exist?(IRB.rc_file)
1819
str += "RUBY_PLATFORM: #{RUBY_PLATFORM}\n"
1920
str += "LANG env: #{ENV["LANG"]}\n" if ENV["LANG"] && !ENV["LANG"].empty?

lib/irb/completion.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ def eval_class_constants
9494
end
9595
}
9696

97+
def inspect
98+
'RegexpCompletor'
99+
end
100+
97101
# Set of reserved words used by Ruby, you should not use these for
98102
# constants or variables
99103
ReservedWords = %w[

lib/irb/input-method.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,10 @@ def initialize
193193
}
194194
end
195195

196+
def completion_info
197+
'RegexpCompletor'
198+
end
199+
196200
# Reads the next line from this input method.
197201
#
198202
# See IO#gets for more information.
@@ -270,6 +274,11 @@ def initialize(completor)
270274
end
271275
end
272276

277+
def completion_info
278+
autocomplete_message = IRB.conf[:USE_AUTOCOMPLETE] ? 'Autocomplete' : 'Tab Complete'
279+
"#{autocomplete_message}, #{@completor.inspect}"
280+
end
281+
273282
def check_termination(&block)
274283
@check_termination_proc = block
275284
end

test/irb/test_cmd.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ def test_irb_info_multiline
9090
Ruby\sversion:\s.+\n
9191
IRB\sversion:\sirb\s.+\n
9292
InputMethod:\sAbstract\sInputMethod\n
93+
Completion: .+\n
9394
\.irbrc\spath:\s.+\n
9495
RUBY_PLATFORM:\s.+\n
9596
East\sAsian\sAmbiguous\sWidth:\s\d\n
@@ -113,6 +114,7 @@ def test_irb_info_singleline
113114
Ruby\sversion:\s.+\n
114115
IRB\sversion:\sirb\s.+\n
115116
InputMethod:\sAbstract\sInputMethod\n
117+
Completion: .+\n
116118
\.irbrc\spath:\s.+\n
117119
RUBY_PLATFORM:\s.+\n
118120
East\sAsian\sAmbiguous\sWidth:\s\d\n
@@ -139,6 +141,7 @@ def test_irb_info_multiline_without_rc_files
139141
Ruby\sversion:\s.+\n
140142
IRB\sversion:\sirb\s.+\n
141143
InputMethod:\sAbstract\sInputMethod\n
144+
Completion: .+\n
142145
RUBY_PLATFORM:\s.+\n
143146
East\sAsian\sAmbiguous\sWidth:\s\d\n
144147
#{@is_win ? 'Code\spage:\s\d+\n' : ''}
@@ -168,6 +171,7 @@ def test_irb_info_singleline_without_rc_files
168171
Ruby\sversion:\s.+\n
169172
IRB\sversion:\sirb\s.+\n
170173
InputMethod:\sAbstract\sInputMethod\n
174+
Completion: .+\n
171175
RUBY_PLATFORM:\s.+\n
172176
East\sAsian\sAmbiguous\sWidth:\s\d\n
173177
#{@is_win ? 'Code\spage:\s\d+\n' : ''}
@@ -196,6 +200,7 @@ def test_irb_info_lang
196200
Ruby\sversion: .+\n
197201
IRB\sversion:\sirb .+\n
198202
InputMethod:\sAbstract\sInputMethod\n
203+
Completion: .+\n
199204
\.irbrc\spath: .+\n
200205
RUBY_PLATFORM: .+\n
201206
LANG\senv:\sja_JP\.UTF-8\n

0 commit comments

Comments
 (0)