Skip to content

Commit

Permalink
Add completion info to irb_info
Browse files Browse the repository at this point in the history
  • Loading branch information
tompng committed Oct 18, 2023
1 parent 7e2b540 commit 8adacb2
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/irb/cmd/irb_info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def execute
str = "Ruby version: #{RUBY_VERSION}\n"
str += "IRB version: #{IRB.version}\n"
str += "InputMethod: #{IRB.CurrentContext.io.inspect}\n"
str += "Completion: #{IRB.CurrentContext.io.respond_to?(:completion_info) ? IRB.CurrentContext.io.completion_info : 'off'}\n"
str += ".irbrc path: #{IRB.rc_file}\n" if File.exist?(IRB.rc_file)
str += "RUBY_PLATFORM: #{RUBY_PLATFORM}\n"
str += "LANG env: #{ENV["LANG"]}\n" if ENV["LANG"] && !ENV["LANG"].empty?
Expand Down
4 changes: 4 additions & 0 deletions lib/irb/completion.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ def eval_class_constants
end
}

def inspect
'RegexpCompletor'
end

# Set of reserved words used by Ruby, you should not use these for
# constants or variables
ReservedWords = %w[
Expand Down
9 changes: 9 additions & 0 deletions lib/irb/input-method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ def initialize
}
end

def completion_info
'RegexpCompletor'
end

# Reads the next line from this input method.
#
# See IO#gets for more information.
Expand Down Expand Up @@ -270,6 +274,11 @@ def initialize(completor)
end
end

def completion_info
autocomplete_message = IRB.conf[:USE_AUTOCOMPLETE] ? 'Autocomplete' : 'Tab Complete'
"#{autocomplete_message}, #{@completor.inspect}"
end

def check_termination(&block)
@check_termination_proc = block
end
Expand Down
5 changes: 5 additions & 0 deletions test/irb/test_cmd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def test_irb_info_multiline
Ruby\sversion:\s.+\n
IRB\sversion:\sirb\s.+\n
InputMethod:\sAbstract\sInputMethod\n
Completion: .+\n
\.irbrc\spath:\s.+\n
RUBY_PLATFORM:\s.+\n
East\sAsian\sAmbiguous\sWidth:\s\d\n
Expand All @@ -113,6 +114,7 @@ def test_irb_info_singleline
Ruby\sversion:\s.+\n
IRB\sversion:\sirb\s.+\n
InputMethod:\sAbstract\sInputMethod\n
Completion: .+\n
\.irbrc\spath:\s.+\n
RUBY_PLATFORM:\s.+\n
East\sAsian\sAmbiguous\sWidth:\s\d\n
Expand All @@ -139,6 +141,7 @@ def test_irb_info_multiline_without_rc_files
Ruby\sversion:\s.+\n
IRB\sversion:\sirb\s.+\n
InputMethod:\sAbstract\sInputMethod\n
Completion: .+\n
RUBY_PLATFORM:\s.+\n
East\sAsian\sAmbiguous\sWidth:\s\d\n
#{@is_win ? 'Code\spage:\s\d+\n' : ''}
Expand Down Expand Up @@ -168,6 +171,7 @@ def test_irb_info_singleline_without_rc_files
Ruby\sversion:\s.+\n
IRB\sversion:\sirb\s.+\n
InputMethod:\sAbstract\sInputMethod\n
Completion: .+\n
RUBY_PLATFORM:\s.+\n
East\sAsian\sAmbiguous\sWidth:\s\d\n
#{@is_win ? 'Code\spage:\s\d+\n' : ''}
Expand Down Expand Up @@ -196,6 +200,7 @@ def test_irb_info_lang
Ruby\sversion: .+\n
IRB\sversion:\sirb .+\n
InputMethod:\sAbstract\sInputMethod\n
Completion: .+\n
\.irbrc\spath: .+\n
RUBY_PLATFORM: .+\n
LANG\senv:\sja_JP\.UTF-8\n
Expand Down

0 comments on commit 8adacb2

Please sign in to comment.