Commit graph

95 commits

Author SHA1 Message Date
Hiroshi SHIBATA
c7bb8d67b7 [ruby/irb] Removed Release Version and Revisions for old VCS software
07fae94862
2023-01-11 22:29:09 +00:00
Patrick Plenefisch
e61b3e6f43 [ruby/irb] Fix https://github.com/ruby/irb/pull/295: Ignore Java
package reference objects in
JRuby

84d030182d
2022-11-17 03:39:04 +00:00
Stan Lo
ca0b592673 [ruby/irb] Don't lazily retrieve gem specs for completion
There are a few downsides of the current approach:

1. Because gem specs are lazily retrieved, this computation happens in
   every irb completion test case, which is not necessary. (In tests we
   don't cache the result of `retrieve_files_to_require_from_load_path`)
2. Gem::Specification.latest_specs is sensible to the content of
   LOAD_PATH. And when combined with 1, tests fail "randomly" if they
   try to mutate LOAD_PATH, even though the test subject it's something
   else.

So by pre-computing and storing the gem paths in a constant, it guarantees
that the computation only happens once and it doesn't get affected by test
cases.

One argument could be made against the change is that, it'll store
unnecessary data for users that disable autocompletion. But the
counter-arguments are:

1. Since autocompletion is enabled by default, this should not be the
   case for most users.
2. For users with autocompletion enabled, IRB already caches the
   result of `retrieve_files_to_require_from_load_path` in memory, which
   should have a similar size of GEM_SPECS. And we currently haven't
   received any report about problems caused by such memory consumption.

c671d39020
2022-11-07 14:44:25 +00:00
st0012
5b3079a8a5 [ruby/irb] Sort constant completion's candidates
ee9b33c817
2022-10-08 03:17:42 +09:00
st0012
7cafe09aec [ruby/irb] Lazily evaluate candidates locals
19a2fcbd87
2022-10-08 03:17:42 +09:00
Imir Kiyamov
83a6213f31 [ruby/irb] Fixed sort of variables in completion
5842888255
2022-10-05 19:22:13 +09:00
osyo-manga
7b88ffb34f [ruby/irb] Change to explicit method call in completion (https://github.com/ruby/irb/pull/369)
Ensure that methods are called even when local variables are defined.
see: https://github.com/ruby/irb/issues/368

c34d54b8bb
2022-10-03 06:55:53 +09:00
st0012
6325fc8854 [ruby/irb] Handle non-String $LOAD_PATH values more carefully
In addition to String values, $LOAD_PATH can also take objects that
respond_to the `to_path` method, like Pathname objects. So `irb` should
be able to handle those objects too.

And if $LOAD_PATH contains objects that can't be converted into String,
`irb` should simply ignore it.

b2f562176b
2022-09-21 22:24:27 +09:00
Kaíque Kandy Koga
5c646ca0a0 [ruby/irb] Ignore parenthesis during completion
Rename method

619aecb412
2021-10-13 06:33:48 +09:00
aycabta
ff26c60bc1 [ruby/irb] Revert "Show original string byte sequence to debug"
This reverts commit b42fe5937a.

b22094a16f
2021-09-24 23:50:32 +09:00
aycabta
93291005a0 [ruby/irb] Show original string byte sequence to debug
7a97bb0e56
2021-09-24 23:50:26 +09:00
aycabta
4704bc0976 Revert "Show original string byte sequence to debug"
This reverts commit b42fe5937a.
2021-09-23 18:02:21 +09:00
Nobuyoshi Nakada
ede95f541b [ruby/irb] Ignore any encoding errors while symbol completion
daa65cded1
2021-09-23 18:01:36 +09:00
aycabta
b42fe5937a Show original string byte sequence to debug 2021-09-23 16:21:06 +09:00
Nobuyoshi Nakada
ee53d97b16 [ruby/irb] Sort shortest files in each load paths
There are two directories where csv*/**/*.rb exist, lib/ and
test/, and depending on the order of tests, test/ may be placed
before lib/.  In that case, as "shortest" names were not sorted,
csv/helper.rb will be the first candidate for "csv".

2af7c6bf71
2021-09-21 23:28:14 +09:00
Nobuyoshi Nakada
c94718e39f [ruby/irb] Check if Gem::Specification is defined
005ade74dd
2021-09-21 23:28:09 +09:00
aycabta
3e038ab1c7 [ruby/irb] Ignore invalid 3 colons in completion
5e29e3e39c
2021-09-11 04:41:20 +09:00
aycabta
bc24af0f35 [ruby/irb] Show lib name first because it's the most common use case
74d635758b
2021-09-08 05:23:56 +09:00
aycabta
c5e8088c7e [ruby/irb] Define absolute_path? by myself for backward compatibility
d9c0dc043e
2021-09-08 05:23:50 +09:00
aycabta
04984415a5 [ruby/irb] Use gem paths to complete "require"
c870b23455
2021-09-08 05:23:45 +09:00
aycabta
6fa37d2666 [ruby/irb] Retrieve completed receiver that is a module or class correctly
b2324727e1
2021-09-04 17:48:20 +09:00
aycabta
4e40b7ddb0 [ruby/irb] Detect the variable class to show doc
33b9bec954
2021-09-02 21:39:55 +09:00
Aleksandar Ivanov
d65d661151 [ruby/irb] Prevent the completion from crashing if rdoc is missing
There are cases where ruby is installed without rdoc and e.g.
lib/irb/cmd/help.rb also handles the LoadError

Here is how to replicate the issue:

```
$ docker run -it alpine:3.13.3 sh

/ # apk add ruby ruby-irb ruby-io-console

/ # irb

irb(main):001:0> Class[TAB][TAB]
```

And you end up with something like:

```
irb(main):001:0> ClassTraceback (most recent call last):
        34: from /usr/bin/irb:23:in `<main>'
        33: from /usr/bin/irb:23:in `load'
        32: from /usr/lib/ruby/gems/2.7.0/gems/irb-1.2.6/exe/irb:11:in `<top (required)>'
        31: from /usr/lib/ruby/2.7.0/irb.rb:400:in `start'
        30: from /usr/lib/ruby/2.7.0/irb.rb:471:in `run'
        29: from /usr/lib/ruby/2.7.0/irb.rb:471:in `catch'
        28: from /usr/lib/ruby/2.7.0/irb.rb:472:in `block in run'
        27: from /usr/lib/ruby/2.7.0/irb.rb:537:in `eval_input'
        26: from /usr/lib/ruby/2.7.0/irb/ruby-lex.rb:150:in `each_top_level_statement'
        25: from /usr/lib/ruby/2.7.0/irb/ruby-lex.rb:150:in `catch'
        24: from /usr/lib/ruby/2.7.0/irb/ruby-lex.rb:151:in `block in each_top_level_statement'
        23: from /usr/lib/ruby/2.7.0/irb/ruby-lex.rb:151:in `loop'
        22: from /usr/lib/ruby/2.7.0/irb/ruby-lex.rb:154:in `block (2 levels) in each_top_level_statement'
        21: from /usr/lib/ruby/2.7.0/irb/ruby-lex.rb:182:in `lex'
        20: from /usr/lib/ruby/2.7.0/irb.rb:518:in `block in eval_input'
        19: from /usr/lib/ruby/2.7.0/irb.rb:704:in `signal_status'
        18: from /usr/lib/ruby/2.7.0/irb.rb:519:in `block (2 levels) in eval_input'
        17: from /usr/lib/ruby/2.7.0/irb/input-method.rb:294:in `gets'
        16: from /usr/lib/ruby/2.7.0/forwardable.rb:235:in `readmultiline'
        15: from /usr/lib/ruby/2.7.0/forwardable.rb:235:in `readmultiline'
        14: from /usr/lib/ruby/2.7.0/reline.rb:175:in `readmultiline'
        13: from /usr/lib/ruby/2.7.0/reline.rb:238:in `inner_readline'
        12: from /usr/lib/ruby/2.7.0/reline.rb:238:in `loop'
        11: from /usr/lib/ruby/2.7.0/reline.rb:239:in `block in inner_readline'
        10: from /usr/lib/ruby/2.7.0/reline.rb:270:in `read_io'
         9: from /usr/lib/ruby/2.7.0/reline.rb:270:in `loop'
         8: from /usr/lib/ruby/2.7.0/reline.rb:311:in `block in read_io'
         7: from /usr/lib/ruby/2.7.0/reline.rb:240:in `block (2 levels) in inner_readline'
         6: from /usr/lib/ruby/2.7.0/reline.rb:240:in `each'
         5: from /usr/lib/ruby/2.7.0/reline.rb:241:in `block (3 levels) in inner_readline'
         4: from /usr/lib/ruby/2.7.0/reline/line_editor.rb:820:in `input_key'
         3: from /usr/lib/ruby/2.7.0/reline/line_editor.rb:608:in `complete'
         2: from /usr/lib/ruby/2.7.0/irb/completion.rb:269:in `block in <module:InputCompletor>'
         1: from /usr/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'
/usr/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require': cannot load such file -- rdoc (LoadError)
```

a2d299c2ac
2021-03-30 14:27:51 +09:00
aycabta
ad8842c06d [ruby/irb] Cache completion files to require
612ebcb311
2021-03-25 18:54:02 +09:00
aycabta
0927756e58 [ruby/irb] Complete require and require_relative
1c61178b4c
2021-03-24 15:11:41 +09:00
Nobuhiro IMAI
f594775230 [ruby/irb] do not escape a predicate method for doc namespace
* Fixes #88

d431a30af4
2021-01-08 13:25:18 +09:00
NARUSE, Yui
3407b7d8a6 Revert "Prefer #send over #__send__ when it is clear there is no possible conflict"
This reverts commit 4dba0c1a8e.

Matz's comment is "send is not deprecated. __send__ is safer".
But "Prefer #send over #__send__" is not reasonable.
2020-11-05 20:54:34 +09:00
Benoit Daloze
4dba0c1a8e Prefer #send over #__send__ when it is clear there is no possible conflict
* Reverts part of 3198e7abd7.
* If the rule is #send should be deprecated, that should be ruled by matz,
  there is no such rule currently and gems seem to prefer #send
  overwhelmingly.
2020-11-05 11:23:27 +01:00
Nobuyoshi Nakada
3198e7abd7
Separate send into public_send and __send__ 2020-10-27 16:12:45 +09:00
Nobuyoshi Nakada
6aa786b8a3 [ruby/irb] Get rid of loading readline unnecessarily
420e7d2270
2020-08-18 14:38:01 +09:00
aycabta
6f0ef83de7 [ruby/irb] Symbol.all_symbols was adopted by Ruby 1.8.0 or later
71ba754e8e
2020-08-18 14:38:01 +09:00
Nobuyoshi Nakada
b08c1bea36 [ruby/irb] Unnamed groups are not captured when named groups are used
0a641a69b0
2020-03-26 17:41:21 +09:00
Koichi Sasada
aa9a38c0ed Ignore incompatible convert of symbols 2020-03-03 15:27:23 +09:00
aycabta
91440ff13f Convert incompatible encoding symbol names 2020-03-03 14:43:14 +09:00
Nobuhiro IMAI
961630126b [ruby/irb] fix reserved words and completion for them
6184b227ad
2020-02-15 21:52:03 +09:00
aycabta
0719e1be11 [ruby/irb] Check doc namespace correctly
IRB::InputCompletor::PerfectMatchedProc crashes when doc not found because a
variable name was incorrect.

889fd4928f
2020-02-12 13:14:28 +09:00
Yusuke Endoh
7e2ed7d1aa [ruby/irb] Add a new easter egg: dancing ruby
e37dc7e58e
2020-02-02 03:22:51 +09:00
Lars Kanis
f451bb5406 [ruby/irb] Fix compatibility with rails before 5.2
Rails before 5.2 added Array#append as an alias to Array#<< ,
so that it expects only one argument.
However ruby-2.5 added Array#append as an alias to Array#push
which takes any number of arguments.

If irb completion is used in `rails c` (for example "IO.<tab>")
it fails with:
  irb/completion.rb:206:in `<<': wrong number of arguments (given 3, expected 1) (ArgumentError)

Using Array#push instead of Array#append fixes compatibility.

5b7bbf9c34
2020-01-20 19:13:19 +09:00
aycabta
7d75e94ea9 Fix regexp to complete complex literal
IRB completion logic always needed exponential notation for complex literal
such as 3e6i but it's bug. I fixed to support complex literal without
exponential notation such as 3i.
2019-11-28 15:22:38 +09:00
aycabta
7769975c3c Remove two removed constants 2019-11-28 08:26:10 +09:00
aycabta
de18328192 Some keywords, "true", "false", and "nil" should be treated as a variable 2019-07-20 02:53:47 +09:00
aycabta
c8ee44f44c Fix showing doc of "nil.to_s", nil doesn't have #name 2019-07-19 08:23:41 +09:00
aycabta
89e178c7cb Fix showing document of ClassName.method_name in IRB
In IRB, Time.new is split as "Time", ".", and "new". The receiver "Time"
is processed by #class method but it means that "Time" changes to
"Class". This commit fixes it.
2019-07-06 07:19:37 +09:00
Nobuyoshi Nakada
976c689ad4
irb: defer requiring rdoc to improve the start up time 2019-06-10 21:18:56 +09:00
aycabta
8d83743170 Use IO.copy_stream 2019-05-29 06:57:47 +09:00
aycabta
a4a682c450 Check RUBY_YES_I_AM_NOT_A_NORMAL_USER env to access RubyVM doc 2019-05-29 06:57:47 +09:00
aycabta
d341bb2857 IRB never show RubyVM's doc 2019-05-29 06:57:47 +09:00
aycabta
d390af3686 Encode completed strings corecctly 2019-05-29 06:54:57 +09:00
aycabta
d5682eb939 Remove unused variable from IRB::InputCompletor 2019-05-28 03:25:47 +09:00
aycabta
0f35c79ad6 Fix number literal regexp of IRB completion 2019-05-27 01:59:17 +09:00