diff options
author | ima1zumi <52617472+ima1zumi@users.noreply.github.com> | 2023-11-21 09:04:36 +0900 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2023-11-21 00:04:41 +0000 |
commit | 7164715666cfbffd5540ee374eee2a5568342d2d (patch) | |
tree | 884e83c437c330c53fc4790e32b112a2175568a5 /test/irb | |
parent | a182b2c5e1dbdbe8960912f8bac076d997a74e65 (diff) | |
download | ruby-7164715666cfbffd5540ee374eee2a5568342d2d.tar.gz |
[ruby/irb] Enable Setting Completer Type through `IRB_COMPLETOR`
(https://github.com/ruby/irb/pull/771)
I propose introducing the capability to set the IRB completion kinds via an environment variable, specifically `IRB_COMPLETOR=type`.
This feature aims to enhance the Rails console experience by allowing Rails users to specify their preferred completion more conveniently.
Currently, when using the Rails console, there's no straightforward way to globally set the type completion across a Rails application repository.
It's possible to configure this setting by placing a `.irbrc` file at the project root. However, using a .irbrc file is not ideal as it allows for broad configurations and can potentially affect the production environment.
My suggestion focuses on allowing users to set the completion to 'type' in a minimal.
This enhancement would be particularly beneficial for teams writing RBS in their Rails applications.
This type completer, integrated with RBS, would enhance completion accuracy, improving the Rails console experience.
https://github.com/ruby/irb/commit/032f6da25f
Diffstat (limited to 'test/irb')
-rw-r--r-- | test/irb/test_init.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/irb/test_init.rb b/test/irb/test_init.rb index e330cc5e84..b6a8f5529b 100644 --- a/test/irb/test_init.rb +++ b/test/irb/test_init.rb @@ -120,6 +120,34 @@ module TestIRB IRB.conf[:USE_AUTOCOMPLETE] = orig_use_autocomplete_conf end + def test_completor_environment_variable + orig_use_autocomplete_env = ENV['IRB_COMPLETOR'] + orig_use_autocomplete_conf = IRB.conf[:COMPLETOR] + + ENV['IRB_COMPLETOR'] = nil + IRB.setup(__FILE__) + assert_equal(:regexp, IRB.conf[:COMPLETOR]) + + ENV['IRB_COMPLETOR'] = 'regexp' + IRB.setup(__FILE__) + assert_equal(:regexp, IRB.conf[:COMPLETOR]) + + ENV['IRB_COMPLETOR'] = 'type' + IRB.setup(__FILE__) + assert_equal(:type, IRB.conf[:COMPLETOR]) + + ENV['IRB_COMPLETOR'] = 'regexp' + IRB.setup(__FILE__, argv: ['--type-completor']) + assert_equal :type, IRB.conf[:COMPLETOR] + + ENV['IRB_COMPLETOR'] = 'type' + IRB.setup(__FILE__, argv: ['--regexp-completor']) + assert_equal :regexp, IRB.conf[:COMPLETOR] + ensure + ENV['IRB_COMPLETOR'] = orig_use_autocomplete_env + IRB.conf[:COMPLETOR] = orig_use_autocomplete_conf + end + def test_completor_setup_with_argv orig_completor_conf = IRB.conf[:COMPLETOR] |