diff options
author | Stan Lo <stan.lo@shopify.com> | 2022-12-06 00:53:28 +0000 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2022-12-06 00:53:32 +0000 |
commit | 9aa18f61f297fcb2ee0cbd4be0772607745274b7 (patch) | |
tree | 93dda6c9752026426c6505ae5f1a972148d64105 /test/irb | |
parent | e31d645da58abce67a0fb8b27251ee532adcfab5 (diff) | |
download | ruby-9aa18f61f297fcb2ee0cbd4be0772607745274b7.tar.gz |
[ruby/irb] Allow disabling autocompletion with
`IRB_USE_AUTOCOMPLETE=false`
(https://github.com/ruby/irb/pull/469)
* Allow using IRB_USE_AUTOCOMPLETE=false to disable autocompletion
Currently, the only 2 ways to disable autocompletion are:
1. Create `.irbrc` and set `IRB.conf[:USE_AUTOCOMPLETE] = false`
2. Add the `--noautocomplete` flag when using the `irb` executable
Both of them are less convenient than setting a env var and are
lesser known to devs.
And given the number of problems the autocompletion has (see #445), I
think we should allow disabling it with a simple `IRB_USE_AUTOCOMPLETE=false`.
* Mention some env var configs in the README
Diffstat (limited to 'test/irb')
-rw-r--r-- | test/irb/test_init.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/irb/test_init.rb b/test/irb/test_init.rb index 9591de1589..d9e338da8d 100644 --- a/test/irb/test_init.rb +++ b/test/irb/test_init.rb @@ -96,6 +96,30 @@ module TestIRB IRB.conf[:USE_COLORIZE] = orig_use_colorize end + def test_use_autocomplete_environment_variable + orig_use_autocomplete_env = ENV['IRB_USE_AUTOCOMPLETE'] + orig_use_autocomplete_conf = IRB.conf[:USE_AUTOCOMPLETE] + + ENV['IRB_USE_AUTOCOMPLETE'] = nil + IRB.setup(__FILE__) + assert IRB.conf[:USE_AUTOCOMPLETE] + + ENV['IRB_USE_AUTOCOMPLETE'] = '' + IRB.setup(__FILE__) + assert IRB.conf[:USE_AUTOCOMPLETE] + + ENV['IRB_USE_AUTOCOMPLETE'] = 'false' + IRB.setup(__FILE__) + refute IRB.conf[:USE_AUTOCOMPLETE] + + ENV['IRB_USE_AUTOCOMPLETE'] = 'true' + IRB.setup(__FILE__) + assert IRB.conf[:USE_AUTOCOMPLETE] + ensure + ENV["IRB_USE_AUTOCOMPLETE"] = orig_use_autocomplete_env + IRB.conf[:USE_AUTOCOMPLETE] = orig_use_autocomplete_conf + end + def test_noscript argv = %w[--noscript -- -f] IRB.setup(eval("__FILE__"), argv: argv) |