Граф коммитов

983 Коммитов

Автор SHA1 Сообщение Дата
tomoya ishida 745ab3e4c7 [ruby/irb] Warn and do nothing if block is passed to measure command
(https://github.com/ruby/irb/pull/813)

https://github.com/ruby/irb/commit/e79a90a1e6
2023-12-13 11:06:26 +00:00
Burdette Lamar 35990cb38c [ruby/irb] [DOC] RDoc for module IRB
(https://github.com/ruby/irb/pull/738)

[DOC] RDoc for module IRB

https://github.com/ruby/irb/commit/f3a0626298
2023-12-12 10:34:38 +00:00
Stan Lo 130268e264 [ruby/irb] Simplify show_source's super calculation
(https://github.com/ruby/irb/pull/807)

https://github.com/ruby/irb/commit/2cccc448de
2023-12-10 04:21:46 +00:00
Stan Lo 5809b75019 [ruby/irb] Debugging command warning should not be specific to the
`debug` command
(https://github.com/ruby/irb/pull/806)

https://github.com/ruby/irb/commit/b7b57311cc
2023-12-07 16:09:15 +00:00
Stan Lo b29ed63883 [ruby/irb] Bump version to v1.10.1
(https://github.com/ruby/irb/pull/801)

https://github.com/ruby/irb/commit/a1e431bd83
2023-12-05 16:34:19 +00:00
Stan Lo f55746a93d [ruby/irb] Disable pager when TERM is not set too
(https://github.com/ruby/irb/pull/802)

https://github.com/ruby/irb/commit/173980974b
2023-12-05 16:32:13 +00:00
Stan Lo ef387e6730 [ruby/irb] Pager should be disabled when TERM=dumb
(https://github.com/ruby/irb/pull/800)

For apps/libs that test against IRB, it's recommended to set `TERM=dumb`
so they get minimum disruption from Reline's interactive-focus features.

Therefore, we should follow the convention to disable pager when `TERM=dumb`.

https://github.com/ruby/irb/commit/8a3002a39e
2023-12-05 16:03:06 +00:00
Stan Lo 52eabf2e32 [ruby/irb] Bump version to v1.10.0
(https://github.com/ruby/irb/pull/798)

https://github.com/ruby/irb/commit/4acc9b8d6c
2023-12-03 17:06:41 +00:00
Gary Tou 4ee1f0fb5d [ruby/irb] Implement `history` command
(https://github.com/ruby/irb/pull/761)

* Implement `history` command

Lists IRB input history with indices. Also aliased as `hist`.

* Add tests for `history` command

* Address feedback: `puts` with multiple arguments instead of `join`ing

* Address feedback: Handle nil from splitting an empty input string

* Refactor line truncation

* Add `-g` grep option to `history` command

* Add `history` command to README

* Remove unused `*args` parameter

* Allow spaces to be included in grep

* Allow `/` to be included in grep regex

* Handle `input` being an empty string

* Exclude "#{index}: " from matching the grep regex

* Add new line after joining

https://github.com/ruby/irb/commit/3f9eacbfa9
2023-12-02 04:32:04 +00:00
hogelog ef466ac931 [ruby/irb] Scrub past history input before split
(https://github.com/ruby/irb/pull/795)

* Scrub past history input before split

* Don't rewrite ENV["LANG"]

https://github.com/ruby/irb/commit/0f344f66d9
2023-12-01 18:04:03 +00:00
Stan Lo f193f96d31 [ruby/irb] Page evaluation result's output
(https://github.com/ruby/irb/pull/784)

* Page evaluation result's output

This will make it easier to work with long output that exceeds the terminal's height.

* Use consistent TERM in rendering tests

This makes sure we get consistent result on all platforms.

https://github.com/ruby/irb/commit/4fedce93d3
2023-11-30 15:22:22 +00:00
tomoya ishida 86d9a6dcb6 [ruby/irb] Use gem repl_type_completor, remove type_completion
implementation
(https://github.com/ruby/irb/pull/772)

https://github.com/ruby/irb/commit/a4868a5373
2023-11-29 16:30:13 +00:00
Peter Zhu fadd28c7ba [ruby/irb] Change show_source tests into integration tests
* Remove trailing spaces

* Migrate show_source tests to integration tests

Because show_source tests often need to define class and/or methods,
they can easily leak state to other tests. Changing them to integration
tests will ensure that they are run in a clean environment.

* Fix NoMethodError caused by SourceFinder#method_target

3c39f13397
2023-11-28 12:22:46 -05:00
paulreece 891ce4614a [ruby/irb] This enhancement allows a user to add the -s flag if they
want to access a methods origin definition.  It allows for chaining
of multiple esses to further go up the classes as needed.
(https://github.com/ruby/irb/pull/770)

https://github.com/ruby/irb/commit/eec1329d5a
2023-11-28 14:56:51 +00:00
Stan Lo a07d84b63c [ruby/irb] Hide debugger hint after the input is submitted
(https://github.com/ruby/irb/pull/789)

If `output_modifier_proc`'s `complete` arg is true, it means the input is
submitted. In that case, debugger hint doesn't provide value to users
and adds noise to the output. So we hide it in such case.

https://github.com/ruby/irb/commit/f86d9dbe2f
2023-11-27 10:34:40 +00:00
Stan Lo cc5d1bf026 [ruby/irb] Display aliases in help message
(https://github.com/ruby/irb/pull/788)

Similar to Pry, it displays user-defined aliases in the help message with
a dedicated section. With the current default aliases, it looks like:

```
...other sections...

Aliases
  $              Alias for `show_source`
  @              Alias for `whereami`
```

https://github.com/ruby/irb/commit/2a0eacc891
2023-11-26 17:07:45 +00:00
Stan Lo 9cd086ba4b [ruby/irb] Support disabling pager
(https://github.com/ruby/irb/pull/783)

With either `IRB.conf[:USE_PAGER] = false` or `--no-pager` commnad line flag.

I decided use `--no-pager` instead of `--use-pager` because it matches with
Pry and git's command line flags.

https://github.com/ruby/irb/commit/df1c3b9042
2023-11-26 11:07:50 +00:00
Stan Lo e8b9058964 [ruby/irb] Hint debugger command in irb:rdbg session
(https://github.com/ruby/irb/pull/768)

When user enters irb:rdbg session, they don't get the same hint that the
`debug` gem provides, like

```
(rdbg) n    # next command
```

This means that users may accidentally execute commands when they want to
retrieve the value of a variable.

So this commit adds a Reline output modifier to add a simiar hint:

```
irb:rdbg(main):002> n # debug command
```

It is not exactly the same as `debug`'s because in this case the importance
is to help users distinguish between value evaluation and debugger command
execution.

https://github.com/ruby/irb/commit/fdf24de851
2023-11-23 07:29:12 +00:00
hogelog e2078ccd5a [ruby/irb] Fix failure of more command with -R option
(https://github.com/ruby/irb/pull/781)

https://github.com/ruby/irb/commit/7d6849e44e
2023-11-23 07:24:35 +00:00
tomoya ishida 8d6175bf64 [ruby/irb] Require prism >= 0.18.0 (MatchWriteNode#targets and
CaseMatchNode)
(https://github.com/ruby/irb/pull/778)

https://github.com/ruby/irb/commit/943c14b12e
2023-11-22 20:29:51 +00:00
tomoya ishida ea60bf912c [ruby/irb] Rescue Exception, ignore warning in completion
doc_namespace
(https://github.com/ruby/irb/pull/777)

https://github.com/ruby/irb/commit/c2f671611a
2023-11-22 12:06:25 +00:00
tomoya ishida f954a5663a [ruby/irb] Bump version to 1.9.1
(https://github.com/ruby/irb/pull/773)

https://github.com/ruby/irb/commit/997df3e849
2023-11-21 13:02:21 +00:00
ima1zumi 7164715666 [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
2023-11-21 00:04:41 +00:00
tomoya ishida 631b500dd5 [ruby/irb] Fix irb crash on `{}.` completion
(https://github.com/ruby/irb/pull/764)

https://github.com/ruby/irb/commit/07e4d540cc
2023-11-18 17:49:06 +00:00
ima1zumi 8044feb7ab [ruby/irb] Bump version to 1.9.0
(https://github.com/ruby/irb/pull/757)

https://github.com/ruby/irb/commit/41548b8bd0
2023-11-10 19:27:30 +00:00
tomoya ishida c4efd17061 [ruby/irb] Add command line option to select which completor to use
(https://github.com/ruby/irb/pull/754)

* Add command line option to select which completor to use

* Add test for completor argv

https://github.com/ruby/irb/commit/1dec2708c9
2023-11-09 13:15:26 +00:00
tomoya ishida e344010465 [ruby/irb] Type based completion using Prism and RBS
(https://github.com/ruby/irb/pull/708)

* Add completor using prism and rbs

* Add TypeCompletion test

* Switchable completors: RegexpCompletor and TypeCompletion::Completor

* Add completion info to irb_info

* Complete reserved words

* Fix [*] (*) {**} and prism's change of KeywordParameterNode

* Fix require, frozen_string_literal

* Drop prism<=0.16.0 support

* Add Completor.last_completion_error for debug report

* Retrieve `self` and `Module.nesting` in more safe way

* Support BasicObject

* Handle lvar and ivar get exception correctly

* Skip ivar reference test of non-self object in ruby < 3.2

* BaseScope to RootScope, move method objects constant under Methods

* Remove unused Splat struct

* Drop deeply nested array/hash type calculation from actual object. Now, calculation depth is 1

* Refactor loading rbs in test, change preload_in_thread not to cache Thread object

* Use new option added in prism 0.17.1 to parse code with localvars

* Add Prism version check and warn when :type completor cannot be enabled

* build_type_completor should skip truffleruby (because endless method definition is not supported)

https://github.com/ruby/irb/commit/1048c7ed7a
2023-11-08 02:46:33 +00:00
tomoya ishida c8d4b103a9 [ruby/irb] Fix dancing-ruby Ctrl+C stop
(https://github.com/ruby/irb/pull/735)

https://github.com/ruby/irb/commit/802b1cb6d8
2023-11-08 09:17:23 +09:00
tomoya ishida db7a4be846 [ruby/irb] Easter egg for autocomplete mode
(https://github.com/ruby/irb/pull/737)

* Show easter-egg inside document dialog in autocomplete mode

* Show more easter_egg(dancing or logo) when Alt+d is pressed in autocomplete mode

https://github.com/ruby/irb/commit/a8e5cc7354
2023-10-28 14:47:46 +00:00
Stan Lo 745879b5ed [ruby/irb] Minor refactors around irb.rb
(https://github.com/ruby/irb/pull/736)

* Remove dead method

* Simplify IRB.version

* Move private Irb methods together

* Centralise @CONF initialization/assignment in init.rb

* Move attr_* calls above initialize method

https://github.com/ruby/irb/commit/cf23be4395
2023-10-21 18:06:00 +00:00
tomoya ishida 177d8ee056 [ruby/irb] Bump version to 1.8.3
(https://github.com/ruby/irb/pull/731)

https://github.com/ruby/irb/commit/de79375ac1
2023-10-14 14:42:37 +00:00
tomoya ishida 4e5c505bad [ruby/irb] Restore IRB::InputCompletor for compatibility
(https://github.com/ruby/irb/pull/730)

https://github.com/ruby/irb/commit/77265efc5f
2023-10-14 14:12:43 +00:00
Stan Lo 3aba21511b [ruby/irb] Bump version to 1.8.2
https://github.com/ruby/irb/commit/47693a2213
2023-10-12 21:36:13 +00:00
tomoya ishida 1126bd8c65 [ruby/irb] Fix require path completion disturbing string method
completion
(https://github.com/ruby/irb/pull/726)

https://github.com/ruby/irb/commit/e42dc74ce0
2023-10-12 16:54:09 +00:00
tomoya ishida cf21c72cdb [ruby/irb] Fix test runner exit bug
(https://github.com/ruby/irb/pull/728)

* Remove useless test setup and teardown that sets MAIN_CONTEXT to nil

* Avoid adding command methods to main object in test

https://github.com/ruby/irb/commit/f204829a08
2023-10-12 13:55:47 +00:00
tomoya ishida e029375a7d [ruby/irb] Decouple RubyLex from prompt and line_no
(https://github.com/ruby/irb/pull/701)

* Remove instance variable prompt and line_no from RubyLex

* Fix prompt test

* Rename prompt generating method and make it private

https://github.com/ruby/irb/commit/1ceb97fe2e
2023-10-12 12:53:31 +00:00
Takashi Kokubun 5140e6a4c3 Fix calling exit if irb_context is nil
Trying to avoid a flaky failure like:
https://github.com/ruby/ruby/actions/runs/6486918029/job/17616113816
2023-10-11 16:22:20 -07:00
tomoya ishida 94cb5765e2 [ruby/irb] Rename current completor to RegexpCompletor and
refactored for future extension
(https://github.com/ruby/irb/pull/707)

* Move completion implementation to completion/regexp_completor for future extension

* Remove constant CompletionProc and PerfectMatchedProc and add a class method

* Move document display logic to InputCompletor. Each completor only need to implement `completion_caididates` and `doc_namespace`

* Move display_document logic to RelineInputMethod

* Use RegexpCompletor directly. Not through class method of InputCompletor.

* RegexpCompletor extends BaseCompletor, move back definition to completion.rb

* Move display_document test to input_method test

* Stop re-initialize completor on each completion phase

* Store completor to ReadlineInputMethod's iver

https://github.com/ruby/irb/commit/1e98521483
2023-10-11 17:09:05 +00:00
Stan Lo cc311e1c45 [ruby/irb] Avoid locking the debug UI to a single thread
(https://github.com/ruby/irb/pull/725)

Since `debug` stores and updates the target thread via its Session's
`@tc` variable, we don't need to and shouldn't lock the UI to the thread
that activates the integration.

https://github.com/ruby/irb/commit/202efdbf0c
2023-10-11 14:16:39 +00:00
Stan Lo b43cc51dca [ruby/irb] Clear all context usages in RubyLex
(https://github.com/ruby/irb/pull/684)

After this change, `RubyLex` will not interact with `Context` directly
in any way. This decoupling has a few benefits:

- It makes `RubyLex` easier to test as it no longer has a dependency on
  `Context`. We can see this from the removal of `build_context` from
  `test_ruby_lex.rb`.
- It will make `RubyLex` easier to understand as it will not be affected
  by state changes in `Context` objects.
- It allows `RubyLex` to be used in places where `Context` is not available.

https://github.com/ruby/irb/commit/d5b262a076
2023-10-04 12:13:33 +00:00
Stan Lo f59b488b5a [ruby/irb] Page show_source's output
(https://github.com/ruby/irb/pull/719)

https://github.com/ruby/irb/commit/3cedc5cb62
2023-09-22 13:00:32 +00:00
Chad Schroeder a8afedce6d [ruby/irb] Handle Concurrent Sessions and Saving Readline::HISTORY
(https://github.com/ruby/irb/pull/651)

* handle concurrent sessions and saving Readline::HISTORY, fixes https://github.com/ruby/irb/pull/510

* separate tests

* don't mutate the HISTORY object on the class

* avoid repeated .to_i calls

* remove intermediary history array

* work with array, fix test comment

---------

https://github.com/ruby/irb/commit/1681ada328

Co-authored-by: Stan Lo <stan001212@gmail.com>
2023-09-16 12:48:32 +00:00
Stan Lo d83b5ea09d [ruby/irb] Bump version to 1.8.1
(https://github.com/ruby/irb/pull/706)

https://github.com/ruby/irb/commit/c7c838a4bf
2023-09-05 13:42:21 +00:00
Stan Lo 3678734fac [ruby/irb] Drop rdoc's version requirement
(https://github.com/ruby/irb/pull/704)

1. The newer versions of rdoc requires pysch 4.0+, which could break apps
   using Ruby 3.0 or 2.7. #703 has more detailed explanation on this.
2. We actually don't use any version-specific rdoc APIs. So having a version
    requirement is not necessary atm.

https://github.com/ruby/irb/commit/3e6ba78c42
2023-08-31 15:44:17 +00:00
Stan Lo 8804a70387 [ruby/irb] Require Reline 0.3.8+
(https://github.com/ruby/irb/pull/702)

Reline 0.3.8 reduces the chance of having a deadlock with the debugger
while using the new `irb:rdbg` integration.

https://github.com/ruby/irb/commit/9b8c56b7d4
2023-08-31 14:08:08 +00:00
Stan Lo 36a3899e9d [ruby/irb] Bump version to 1.8.0
(https://github.com/ruby/irb/pull/700)

https://github.com/ruby/irb/commit/a061744ed3
2023-08-30 09:17:06 +00:00
Stan Lo f37f357e80 [ruby/irb] Improve help/show_cmds message during debugger
integration
(https://github.com/ruby/irb/pull/693)

* `help` should display debugger's help during irb:rdbg session

* Update `show_cmds`'s output when in irb:rdbg session

https://github.com/ruby/irb/commit/4029c2e564
2023-08-29 18:36:16 +00:00
Stan Lo 6ed1a504d4 [ruby/irb] irb:rdbg cleanups (https://github.com/ruby/irb/pull/697)
* Remove unused method and constant from IRB::Debug

* Update comments

https://github.com/ruby/irb/commit/98914a963c
2023-08-29 12:54:25 +00:00
Stan Lo 221c2d0e19
[ruby/irb] Print deprecation message for prompt_n methods
(https://github.com/ruby/irb/pull/691)

They were removed in #685, but we should still keep them to avoid breaking
changes to tools like Chef.

533ff08947/lib/chef/shell.rb (L138)

https://github.com/ruby/irb/commit/b585e0c835
2023-08-29 18:15:05 +09:00
Summer ☀️ 0cd92819c9
[ruby/irb] Remove unused `PROMPT_N`
(https://github.com/ruby/irb/pull/685)

https://github.com/ruby/irb/commit/66e69fa0dc
2023-08-29 18:15:05 +09:00
Stan Lo e1d7066a5f [ruby/irb] Deprecate RubyLex and warn about referencing to it
(https://github.com/ruby/irb/pull/692)

`RubyLex` has always been a private component of IRB, so we should
explicitly discourage usages of it.
Also, it should be placed under the `IRB` module like other components.

https://github.com/ruby/irb/commit/069b5625f7
2023-08-24 15:35:40 +00:00
Stan Lo ca6db02c2a [ruby/irb] Avoid overriding user's `irb_name` setting in debugger
integration
(https://github.com/ruby/irb/pull/688)

* Avoid overriding user's irb_name setting in debugger integration

Instead of always setting `irb_name` to `irb:rdbg`, it should respect
the user's setting and only append `:rdbg` to it.

* Introduce write_rc test helper

https://github.com/ruby/irb/commit/2ce7593351
2023-08-21 18:23:32 +00:00
Stan Lo 86ac17efde [ruby/irb] Move input processing out of RubyLex
(https://github.com/ruby/irb/pull/683)

* Add a test case for Ctrl-C handling

* Test symbol aliases with integration tests

There are a few places that also need to check symbol aliases before
`Irb#eval_input`. But since the current command test skip them, we
don't have test coverage on them.

* Move each_top_level_statement and readmultiline to Irb

This will save RubyLex from knowning information about commands and aliases.

https://github.com/ruby/irb/commit/69cb5b5615
2023-08-21 15:42:15 +00:00
Summer ☀️ 725ca2f9d8 [ruby/irb] Support `VISUAL` env var, and prefer it over `EDITOR`
(https://github.com/ruby/irb/pull/686)

* Support `VISUAL` env var, and prefer it over `EDITOR`

* Update test/irb/test_cmd.rb

---------

https://github.com/ruby/irb/commit/399b872c31

Co-authored-by: Stan Lo <stan001212@gmail.com>
2023-08-20 17:22:01 +00:00
Stan Lo 5a40f7db54 [ruby/irb] Encapsulate input details in Statement objects
(https://github.com/ruby/irb/pull/682)

* Introduce Statement class

* Split Statement class for better clarity

https://github.com/ruby/irb/commit/65e8e68690
2023-08-16 10:13:46 +00:00
Stan Lo 7f8f62c93b [ruby/irb] Support seamless integration with ruby/debug
(https://github.com/ruby/irb/pull/575)

* Support native integration with ruby/debug

* Prevent using multi-irb and activating debugger at the same time

Multi-irb makes a few assumptions:

- IRB will manage all threads that host sub-irb sessions
- All IRB sessions will be run on the threads created by IRB itself

However, when using the debugger these assumptions are broken:

- `debug` will freeze ALL threads when it suspends the session (e.g. when
  hitting a breakpoint, or performing step-debugging).
- Since the irb-debug integration runs IRB as the debugger's interface,
  it will be run on the debugger's thread, which is not managed by IRB.

So we should prevent the 2 features from being used at the same time.
To do that, we check if the other feature is already activated when
executing the commands that would activate the other feature.

https://github.com/ruby/irb/commit/d8fb3246be
2023-08-13 18:30:34 +00:00
Stan Lo 9099d62ac7 [ruby/irb] Move IO configuration to IRB::Irb
(https://github.com/ruby/irb/pull/681)

It shouldn't be `RubyLex`'s responsibility to handle IO. So this moves
the configuration to `IRB::Irb`.

https://github.com/ruby/irb/commit/daff750076
2023-08-13 15:23:04 +00:00
Nobuyoshi Nakada 3af5badae8 [ruby/irb] Remove useless `begin`/`end` [ci skip]
(https://github.com/ruby/irb/pull/680)

The `rescue` was removed at https://github.com/ruby/irb/commit/420e7d227011.

https://github.com/ruby/irb/commit/8fa688e9c0
2023-08-13 15:02:29 +00:00
tomoya ishida e1683b4958 [ruby/irb] Drop showing indent level number in DEFAULT prompt and
INF_RUBY prompt
(https://github.com/ruby/irb/pull/679)

* Drop showing indent level number in DEFAULT prompt and INF_RUBY prompt

* Update prompt part of test_rendering's expected result

https://github.com/ruby/irb/commit/3847532e54
2023-08-12 10:19:24 +00:00
Stan Lo 680835085d [ruby/irb] Reline/ReadlineInputMethod should inherit
StdioInputMethod
(https://github.com/ruby/irb/pull/671)

They are both built on top of stdio and are basically extended version
of StdioInputMethod. They also share several attributes and methods with
StdioInputMethod.

https://github.com/ruby/irb/commit/c5f5abdbde
2023-08-12 10:17:52 +00:00
tomoya ishida d42891079f [ruby/irb] Remove needless removal of trailing whitespace in
check_code_state
(https://github.com/ruby/irb/pull/678)

https://github.com/ruby/irb/commit/4a6af7d1ed
2023-08-11 18:51:25 +00:00
Stan Lo 0781e55206 [ruby/irb] Move assignment check to RubyLex
(https://github.com/ruby/irb/pull/670)

Since assignment check relies on tokenization with `Ripper`, it feels like
the responsibility of `RubyLex`. `Irb#eval_input` should simply get the result
when calling `each_top_level_statement` on `RubyLex`.

https://github.com/ruby/irb/commit/89d1adb3fd
2023-08-11 18:44:52 +00:00
Stan Lo d3311e5cc3 [ruby/irb] Add black and white color to IRB::Color
(https://github.com/ruby/irb/pull/676)

https://github.com/ruby/irb/commit/a2763acade
2023-08-11 16:03:11 +00:00
Stan Lo ab0f90f1f5 [ruby/irb] Fix nested IRB sessions' history saving
(https://github.com/ruby/irb/pull/652)

1. Dynamically including `HistorySavingAbility` makes things unnecessarily
   complicated and should be avoided.
2. Because both `Reline` and `Readline` use a single `HISTORY` constant
   to store history data. When nesting IRB sessions, only the first IRB
   session should handle history loading and saving so we can avoid
   duplicating history.
3. History saving callback should NOT be stored in `IRB.conf` as it's
   recreated every time `IRB.setup` is called, which would happen when
   nesting IRB sessions.

https://github.com/ruby/irb/commit/0fef0ae160
2023-08-09 14:57:52 +00:00
Stan Lo 0387b86c3a [ruby/irb] Remove unused `InputMethod#initialize`
(https://github.com/ruby/irb/pull/635)

* Remove unused InputMethod#initialize

The constructor takes a `file_name` argument, but it is never used. The
only input method that needs a file is `FileInputMethod`, which has its
own constructor to take a file object directly.

So the constructor in `InputMethod` is not needed and its child classes
don't need to call `super` in their constructors.

* Remove unused FileInputMethod#file_name

https://github.com/ruby/irb/commit/153b1e9d1c
2023-08-07 15:30:13 +00:00
Stan Lo 32e828bb4a [ruby/irb] Deprecate multi-irb commands
(https://github.com/ruby/irb/pull/654)

* Deprecate multi-irb commands

- Print deprecated message when any of the commands are used
- Put related commands under `Multi-irb` category with a deprecated
  label

* Update readme

https://github.com/ruby/irb/commit/861731ac12
2023-08-02 18:35:08 +00:00
Stan Lo 201fd57518 [ruby/irb] Drop src_encoding.rb
(https://github.com/ruby/irb/pull/634)

Its method `IRB.default_src_encoding` was only used in `magic-file.rb`,
which has been removed.

https://github.com/ruby/irb/commit/ed98983b1f
2023-08-02 18:17:27 +09:00
Stan Lo f11ac06337 [ruby/irb] Add workspace category
(https://github.com/ruby/irb/pull/661)

* Create a new Workspace command category

* Update readme

https://github.com/ruby/irb/commit/310650c213
2023-08-01 12:51:30 +00:00
Stan Lo 5d78ec8a94 [ruby/irb] Decouple `edit` and `show_source` commands
(https://github.com/ruby/irb/pull/658)

* Decouple `edit` command from `show_source`

2 commands should not depend on each other. If `edit` command also needs
to find a source, the source finding logic should be extracted into a
separate class.

* Return nil if is not an actual file path

* Refactor SourceFinder

https://github.com/ruby/irb/commit/9790517a0c
2023-07-31 19:57:36 +00:00
Stan Lo 283b2fdab4 [ruby/irb] Page `ls`'s output (https://github.com/ruby/irb/pull/657)
* Page ls command's output

* Use Pager.page_content in show_cmds too

https://github.com/ruby/irb/commit/82d1687302
2023-07-26 08:32:02 +00:00
Stan Lo d8cee55073 [ruby/irb] Display `show_cmds`'s output in a pager when in TTY
environment
(https://github.com/ruby/irb/pull/647)

This can:

- Make it easier to scroll up and down the commands list
- Avoid pushing up users' previous output
- Allow users to do basic search with `/<word>`

https://github.com/ruby/irb/commit/f94e8a66dd
2023-07-25 18:33:23 +00:00
Stan Lo 0db58dd0db [ruby/irb] Declare rdoc as dependency
(https://github.com/ruby/irb/pull/648)

IRB already has several features that rely on rdoc, such as:

- Autocompletion's document dialog
- Autocompletion's `PerfectMatchedProc`
- The `show_doc` command
- Easter egg

And we could use its pager more in the future too. So it makes sense to
declare rdoc as a dependency instead of relying on the one bundled with
Ruby.

https://github.com/ruby/irb/commit/4dffbb1dd3
2023-07-18 13:53:31 +00:00
tomoya ishida be98bfc4ee [ruby/irb] Indent multiline percent literals
(https://github.com/ruby/irb/pull/643)

https://github.com/ruby/irb/commit/18bb4022a9
2023-07-15 18:12:05 +00:00
ima1zumi 7ffb995f5e [ruby/irb] Bump 1.7.4 (https://github.com/ruby/irb/pull/645)
https://github.com/ruby/irb/commit/b0f650a766
2023-07-15 15:59:18 +00:00
Stan Lo 174bc22570 [ruby/irb] Fix history-saving feature
(https://github.com/ruby/irb/pull/642)

* Define RelineInputMethod::HISTORY

The HistorySavingAbility module doesn't do anything if the input method
class doesn't define HISTORY.

- 3ac96be660/lib/irb/history.rb (L10)
- 3ac96be660/lib/irb/history.rb (L34)

This patch defines RelineInputMethod::HISTORY to avoid this.

* Improve history-saving's ability check

Instead of checking the existence of `input_method_class::HISTORY`, we should
make every input method class declare if it supports history saving or not.

Since the default value is `false`, it shouldn't break any custom input method
that inherits from `IRB::InputMethod`.

https://github.com/ruby/irb/commit/aec7a5b3f5
2023-07-14 15:45:09 +00:00
Stan Lo 7f9c2a9bdd [ruby/irb] Bump version to 1.7.3
(https://github.com/ruby/irb/pull/639)

https://github.com/ruby/irb/commit/621c8c2b7d
2023-07-13 02:16:04 +00:00
Stan Lo 81beb29988 [ruby/irb] Correct preferred_dialog_height's caller
(https://github.com/ruby/irb/pull/638)

The caller should be the dialog itself, not Reline.

https://github.com/ruby/irb/commit/418c2b945e
2023-07-12 19:55:19 +00:00
ima1zumi d40935c680 [ruby/irb] Bump version to 1.7.2
(https://github.com/ruby/irb/pull/636)

https://github.com/ruby/irb/commit/85d6b4d146
2023-07-11 16:30:34 +00:00
ima1zumi 4be92463b6 [ruby/irb] Require Reline 0.3.6 or higher
(https://github.com/ruby/irb/pull/632)

* Require Reline 0.3.6 or higher

"Multi-line multibyte regular expression raises exception" (https://github.com/ruby/irb/issues/627) is fixed in Reline 0.3.6.

* Remove unnecessary conditional
2023-07-11 14:47:26 +00:00
Stan Lo 4e2f98be39 [ruby/irb] Avoid using Reline as a module
(https://github.com/ruby/irb/pull/633)

Using it as a module makes it harder to understand methods' source.
2023-07-09 06:25:08 +00:00
Andy Waite fd6da40fef [ruby/irb] Use `max_by` for `longest_cmd_name_length`
(https://github.com/ruby/irb/pull/628)

https://github.com/ruby/irb/commit/5e87f3bfdd

Co-authored-by: Andy Waite <andyw8@users.noreply.github.com>
2023-07-04 20:45:07 +00:00
Stan Lo f6af5a1128 [ruby/irb] Refactor eval history
(https://github.com/ruby/irb/pull/623)

* Rename `ext/history.rb` to `ext/eval_history.rb`

To confusion with `lib/irb/history.rb`

* Add eval_history tests

* Rename eval_history's History to EvalHistory to avoid confusion
2023-07-04 15:17:41 +00:00
Stan Lo af9eeb19d8 [ruby/irb] Stop treating history-saving logic as extension
(https://github.com/ruby/irb/pull/613)

Since `IRB.conf[:SAVE_HISTORY]` is assigned with 1000 by default, history-saving
is a feature enabled by default. So it should not be treated as an extension,
which adds unnecessary complexity to the code.
2023-07-03 13:48:23 +00:00
Stan Lo 4bad2a9562 [ruby/irb] Bump version to 1.7.1
(https://github.com/ruby/irb/pull/621)

https://github.com/ruby/irb/commit/b9a9dd97df
2023-07-02 04:49:07 +00:00
Stan Lo 136fcd5118 [ruby/irb] Reduce internal operations' exposure to benchmarking
(https://github.com/ruby/irb/pull/618)

* Test last value is assigned with measure enabled

* Remove unnecessary `result` variable

`Context#evaluate` always assigns the result of the evaluation to `_` so
we don't need to do it in `Irb#eval_input`.

* Move benchmarking logic into `Context#evaluate`

Current location of the benchmarking logic is too high up and includes
operations like command loading and argument transformation, which should
be excluded. So this commit moves it into `Context#evaluate` to reduce the
noise.

We don't move it further down to `Workspace#evaluate` because `Context`
is an argument of the measure block, which is not available in `Workspace`.
2023-06-30 17:42:00 +00:00
tomoya ishida 9398734010 [ruby/irb] Re-implement prev_spaces feature for pasted code
(https://github.com/ruby/irb/pull/607)

https://github.com/ruby/irb/commit/9d97a192a5
2023-06-30 14:23:24 +00:00
tomoya ishida 8aedfefb21 [ruby/irb] Remove keyword exception from Context#evaluate because
the value is always nil
(https://github.com/ruby/irb/pull/617)

https://github.com/ruby/irb/commit/62691384f8
2023-06-27 20:43:53 +00:00
Stan Lo caddd0274b [ruby/irb] Move input line mutation out of `Context#evaluate`
(https://github.com/ruby/irb/pull/615)

This makes sure `Context#evaluate` really just evaluates the input.
It will also make #575's implementation cleaner.
2023-06-27 19:51:18 +00:00
tomoya ishida 00216c8aa0 [ruby/irb] Fix process_continue(rename to should_continue?) and
check_code_block(rename to check_code_syntax)
(https://github.com/ruby/irb/pull/611)

https://github.com/ruby/irb/commit/b7f4bfaaa4
2023-06-25 05:12:16 +00:00
tomoya ishida 406799cae8 [ruby/irb] Omit nesting_level, use indent_level to build prompt
string
(https://github.com/ruby/irb/pull/610)

https://github.com/ruby/irb/commit/f01ff0811b
2023-06-24 22:20:43 +00:00
tomoya ishida e25403d0d9 [ruby/irb] Improve indentation: bugfix, heredoc, embdoc, strings
(https://github.com/ruby/irb/pull/515)

* Implement heredoc embdoc and string indentation with bugfix

* Fix test_ruby_lex's indentation value

* Add embdoc indent test

* Add workaround for lines==[nil] passed to auto_indent when exit IRB with CTRL+d
2023-06-20 15:13:43 +00:00
tomoya ishida b8cd79c82f [ruby/irb] Add missing token that ignored by ripper
(https://github.com/ruby/irb/pull/608)

https://github.com/ruby/irb/commit/1cd3b45402
2023-06-19 10:38:24 +00:00
tomoya ishida 364a6d56d7 [ruby/irb] Rewrite RubyLex to fix some bugs and make it possible to
add new features easily
(https://github.com/ruby/irb/pull/500)

* Add nesting level parser for multiple use (indent, prompt, termination check)

* Rewrite RubyLex using NestingParser

* Add nesting parser tests, fix some existing tests

* Add description comment, rename method to NestingParser

* Add comments and tweak code to RubyLex

* Update NestingParser test

* Extract list of ltype tokens to constants
2023-06-15 15:39:58 +00:00
tomoya ishida 5d91be7c1f [ruby/irb] Use symbol.inspect instead of ":"+symbol.id2name to avoid
completion candidates including newline characters
(https://github.com/ruby/irb/pull/539)

https://github.com/ruby/irb/commit/aaf0c46645
2023-06-13 10:46:38 +00:00
Stan Lo e1ccb2838b [ruby/irb] Use `Kernel.warn` to print command alias warning
(https://github.com/ruby/irb/pull/601)

This aligns with other warnings in irb and properly channel the message
to stderr.
2023-06-10 15:01:46 +00:00
Stan Lo a41e088604 [ruby/irb] Remove the unused fork command definition
(https://github.com/ruby/irb/pull/600)

https://github.com/ruby/irb/commit/b039b89343
2023-06-10 12:51:38 +00:00
Stan Lo 45ff2f4a89 [ruby/irb] Refactor ExtendCommand::Nop
(https://github.com/ruby/irb/pull/598)

* Rename conf to irb_context

* Drop Nop#irb method because it's only used by irb/ext/loader.rb

We don't need to expose this method to all command classes, especially
when it's just an alias of `irb_context.irb`.
2023-06-05 19:12:16 +00:00
Stan Lo 273b38475e [ruby/irb] Simplify irb_info command
(https://github.com/ruby/irb/pull/597)

https://github.com/ruby/irb/commit/0a0409c52b
2023-06-05 19:02:43 +00:00
ima1zumi 76ee4edb97 [ruby/irb] Fixed string escaping omissions
(https://github.com/ruby/irb/pull/599)

I received a `RegexpError` when I typed `::Array[`.
::Array[/Users/mi/ghq/github.com/ruby/irb/lib/irb/completion.rb:236:in `retrieve_completion_data': premature end of char-class: /^Array[/ (RegexpError)
2023-06-05 18:34:10 +00:00
Stan Lo 4275a8098e [ruby/irb] Bump version to 1.7.0
(https://github.com/ruby/irb/pull/596)

https://github.com/ruby/irb/commit/c2e7002867
2023-06-04 15:24:30 +00:00
tomoya ishida d5ef373b11 [ruby/irb] Set maximum document dialog height by
preferred_dialog_height provided by Reline
(https://github.com/ruby/irb/pull/591)

https://github.com/ruby/irb/commit/df6907aca9
2023-05-28 09:20:18 +00:00
TSUYUSATO Kitsune 92d6c9a7b1 [ruby/irb] Allow `show_source` for private methods
(https://github.com/ruby/irb/pull/589)

* Allow `show_source` for private methods

Fix https://github.com/ruby/irb/pull/577

* Pend tests on TruffleRuby

It seems `eval(..., __LINE__ + 1)` does not work.
Other similar tests are also pended on TruffleRuby, so I think it
is acceptable.

* Use `private_method_defined?` instead of `defined?`
2023-05-23 16:16:37 +00:00
tomoya ishida e8c9f727e8 [ruby/irb] Simplify each_top_level_statement
(https://github.com/ruby/irb/pull/576)

* Simplify each_top_level_statement, reduce instance vars

* Update lib/irb/ruby-lex.rb

Co-authored-by: Stan Lo <stan001212@gmail.com>

* Remove unused ltype from TestRubyLex#check_state response

* Remove unnecessary const path of TerminateLineInput

* Combine duplicated code state check into method

---------

https://github.com/ruby/irb/commit/172453cec4

Co-authored-by: Stan Lo <stan001212@gmail.com>
2023-05-19 13:48:08 +00:00
Adam Daniels b54b388f2a [ruby/irb] Display mod key as `Option` on Darwin platforms
(https://github.com/ruby/irb/pull/584)

Check RUBY_PLATFORM for `darwin` and modify the mod key from `Alt` to
`Option`.
2023-05-19 01:33:32 +00:00
Stan Lo cfb7997353 [ruby/irb] Refactor RubyLex's input/io methods
(https://github.com/ruby/irb/pull/583)

1. Make `RubyLex#set_input` simply assign the input block. This matches
   the behavior of `RubyLex#set_prompt`.
2. Merge `RubyLex#set_input`'s IO configuration logic with `#set_auto_indent`
   into `#configure_io`.
2023-05-18 19:00:33 +00:00
Stan Lo b695f58d52 [ruby/irb] Print deprecation warning for `help` command
(https://github.com/ruby/irb/pull/567)

* Give show_doc its own command class

* Print deprecation warning for `help` command
2023-05-18 03:28:31 +00:00
Stan Lo e9930b51b2 [ruby/irb] Retire magic-file.rb
(https://github.com/ruby/irb/pull/574)

`MagicFile` was introduced around v0.9.6, which was like 14~15 years ago.
It was needed because back then we needed to read a file's magic comment
to determine the encoding of it, and read it with that encoding.

Commit: 3ee79e89

But now we expect files to be encoded in UTF-8 and don't specify encoding
through magic comments anymore, `MagicFile` can be retired.
2023-04-28 17:20:20 +00:00
Stan Lo 5cd4f35da6 [ruby/irb] Simplify Locale#load
(https://github.com/ruby/irb/pull/571)

* Simplify Locale#load

Instead of loading file content with `MagicFile` and then evaluting it,
we can just use `Kernel.load` to load the file.

* Remove unused optional argument

* Remove unused Locale#require and #toplevel_load
2023-04-27 15:42:21 +00:00
Stan Lo a58cae77f7 [ruby/irb] Stop using MagicFile for printing help messages
(https://github.com/ruby/irb/pull/573)

`MagicFile` was introduced around v0.9.6, which was like 14~15 years ago.
It was needed because back then we needed to read a file's magic comment
to determine the encoding of it, and read it with that encoding.

Commit: 3ee79e89ad

But now both EN and JA's help-message file are UTF-8 and have removed the
encoding comment, we don't need to open them with `MagicFile` anymore.
2023-04-27 11:07:05 +00:00
Stan Lo fe0b23b42f [ruby/irb] Remove encoding_aliases.rb
(https://github.com/ruby/irb/pull/569)

We don't have to load another file to define the legacy encoding aliases
map because there's only one definition of it. We can define it in
locale.rb directly.
2023-04-26 15:06:05 +00:00
Stan Lo 299d17a2f1
[ruby/irb] Fix Locale's encoding lookup for Japanese encodings
(https://github.com/ruby/irb/pull/568)

In 3ee79e89ad,
`encoding_aliases.rb` was introduced to return the correct encoding object for
`ujis` and `euc` encodings.

However, the return value of `@@legacy_encoding_alias_map[@encoding_name]`
is always overridden by a second look up with `Encoding.find(@encoding_name)`.
So the logic didn't work as expected.

This commit fixes the problem.
2023-04-26 13:13:25 +09:00
Stan Lo 73fc81199d [ruby/irb] Simplify the help command's implementation
(https://github.com/ruby/irb/pull/564)

The current method-redefining approach brings little benefit, makes it
harder to understand the code, and causes warnings like:

> warning: method redefined; discarding old execute

This patch simplifies it while displaying more helpful message when rdoc
couldn't be loaded.
2023-04-24 14:10:36 +00:00
Stan Lo 805899dda2 [ruby/irb] Filter out top-level methods when using `ls
<Class/Module>`
(https://github.com/ruby/irb/pull/562)

Instead of always printing methods inherited from Class or Module, IRB by
default should filter them out unless `<Class/Module>` is specified to be
either of those.
2023-04-24 14:05:16 +00:00
Yusuf Daniju ec211ad54d [ruby/irb] fix typo in tracer (https://github.com/ruby/irb/pull/565)
https://github.com/ruby/irb/commit/2f567f3d3e
2023-04-23 18:41:40 +00:00
ima1zumi f7c8d3bf96 [ruby/irb] Bump version to 1.6.4
(https://github.com/ruby/irb/pull/560)

https://github.com/ruby/irb/commit/01328da9b6
2023-04-09 13:44:12 +00:00
Stan Lo e7f77e1e89 [ruby/irb] Simplify command method definition
(https://github.com/ruby/irb/pull/559)

* Remove unnecessary command argument generation code

Now that all the supported Ruby versions handle splat args and splat kwargs,
we don't need that args generation code anymore.

* Remove unused command definition code

If we look at `@EXTEND_COMMANDS`, all commands are defined in a file, which
means the `if load_file` branch is always executed. Therefore we can drop
the else branch of that condition.

* Avoid defining unnecessary command methods

There's no need to define another command method just to call `Command.execute`.
2023-04-08 10:11:50 +00:00
Stan Lo 2f8e5c80e6 [ruby/irb] Drop Ruby 2.6 support
(https://github.com/ruby/irb/pull/555)

* Remove all Ruby 2.6 support

* Drop Ruby 2.6 specific testing conditions

* Only run Ruby 2.7+ on CI

* Bump Ruby requirement to 2.7+

https://github.com/ruby/irb/commit/3f714b616c
2023-04-05 21:40:40 +00:00
Stan Lo cd94bcdc46 [ruby/irb] Don't check RUBY_ENGINE when deciding whether to accept kargs
Ruby implementations like JRuby and TruffleRuby already indicate their
compatibility target with RUBY_VERSION. We don't need to exclude
them from accepting keyword arguments as long as they target 2.7+.

https://github.com/ruby/irb/commit/bf20faa4e6

Co-authored-by: Kevin Menard <kevin@nirvdrum.com>
2023-04-02 15:34:28 +00:00
Stan Lo f25791884c [ruby/irb] Remove dead code (https://github.com/ruby/irb/pull/554)
* Remove unused ATTR_TTY and ATTR_PLAIN constants

They were added in d7d26b51bf

But the references were removed in 1c76845cca

Co-authored-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>

* Remove unused MethodExtender module

It was added in 6cc5d718d7
but it's not used anywhere.

Co-authored-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>

* Remove unused IRB.irb_at_exit

It's not used after aaf4eb4e98

Co-authored-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>

* Remove unused InputCompletor.ignored_modules

It was added in 88311ce3c8
but the reference was removed in 78c74d2425

* Remove unused TracerLoadError constant

This constant was added in cb50fa3738
but never referenced.

---------

https://github.com/ruby/irb/commit/7de0234325

Co-authored-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
2023-04-02 14:11:12 +00:00
Stan Lo 309ff928f5 [ruby/irb] Replace METHOD_IS_A with ===
(https://github.com/ruby/irb/pull/542)

https://github.com/ruby/irb/commit/edd6c30e16
2023-03-13 18:11:58 +00:00
Stan Lo 1095baed34 [ruby/irb] Support inspecting BasicObject
(https://github.com/ruby/irb/pull/541)

https://github.com/ruby/irb/commit/1dc2a406a3
2023-03-13 14:31:37 +00:00
Stan Lo 56ebeba436 [ruby/irb] Bump version to 1.6.3
(https://github.com/ruby/irb/pull/537)

https://github.com/ruby/irb/commit/110e4a3219
2023-03-07 02:47:15 +00:00
tomoya ishida 0463c5806a [ruby/irb] Improve method completion for string and regexp that
includes word break characters
(https://github.com/ruby/irb/pull/523)

* Improve method completion for string and regexp that includes word break characters

* Remove completion-test's assert_not_include because candidates no longer include every possible methods

* Add comment about string's method completion regexp

Co-authored-by: Stan Lo <stan001212@gmail.com>

* Add comment about regexp's method completion regexp

Co-authored-by: Stan Lo <stan001212@gmail.com>

---------

https://github.com/ruby/irb/commit/aa8128c533

Co-authored-by: Stan Lo <stan001212@gmail.com>
2023-03-06 05:52:46 +00:00
Stan Lo 191e4ae33f [ruby/irb] Drop chained methods' completion support
(https://github.com/ruby/irb/pull/529)

Consider completion for this example: `foo.bar.b`

Without type information, it is hard to know the return value of the `bar`
method, so the current implementation interates through `ObjectSpace` to
get all possible candidates for the second method.

In small projects, the performance and accuracy are acceptable. But in
bigger projects, the performance is unacceptable and the accuracy is mostly
poor.

So this commit drops the support for chained methods' completion.
2023-03-04 15:34:49 +00:00
tomoya ishida b49053a6be [ruby/irb] Avoid slow symbol completion when completion target is an
empty symbol
(https://github.com/ruby/irb/pull/534)

https://github.com/ruby/irb/commit/35697f3ef3
2023-03-03 13:41:21 +00:00
Stan Lo da6ac30d1e [ruby/irb] Specify metadata to provide richer information on
rubygems.org
(https://github.com/ruby/irb/pull/532)

https://github.com/ruby/irb/commit/f01c2a6ac1
2023-03-02 13:49:03 +00:00
Stan Lo 9ddd73060b [ruby/irb] Display and prioritise instance methods in `ls
<module/class>`
(https://github.com/ruby/irb/pull/496)

https://github.com/ruby/irb/commit/e3d21f9329
2023-02-28 14:36:12 +00:00
Stan Lo ea830ab29d [ruby/irb] Add a comment about Rails' patch on
Workspace#filter_backtrace
(https://github.com/ruby/irb/pull/526)

* Add a comment about Rails' patch on Workspace#filter_backtrace

* Update lib/irb/workspace.rb

Co-authored-by: Sorah Fukumori <sora134@gmail.com>

---------

https://github.com/ruby/irb/commit/9443d911fc

Co-authored-by: Sorah Fukumori <sora134@gmail.com>
2023-02-27 15:23:31 +00:00
Stan Lo 0aa50a03b1 [ruby/irb] Provide more useful message when
`IRB::Inspector#inspect_value` errors
(https://github.com/ruby/irb/pull/511)

**Before**

```
irb(main):001:0> c = Cat.new "foo"
(Object doesn't support #inspect)
=>
```

**After**

```
irb(main):001:0> c = Cat.new "foo"
An error occurred when inspecting the object: #<NoMethodError: undefined method `is_a?' for foo:Cat

      if obj.is_a?(String)
            ^^^^^^>
Result of Kernel#inspect: #<Cat:0x0000000109090d80 @name="foo">
=>
```
2023-02-27 11:07:19 +00:00
ima1zumi 672b81b090 [ruby/irb] Remove unused Struct
(https://github.com/ruby/irb/pull/522)

https://github.com/ruby/irb/commit/97dae166ae
2023-02-25 16:50:33 +00:00
Stan Lo cbac0fa4cb [ruby/irb] Remove unused context argument from Worksapce#evaluate
(https://github.com/ruby/irb/pull/488)

The context argument was introduced in this change:

6806669d17 (diff-296327851fb7a2c307c2d0693b769f58c01aaf315972f290500d10081ee200a9)

perhaps for potential usages. But after that it's never used.
2023-02-18 11:34:28 +00:00
HASUMI Hitoshi 3a9d52466a [ruby/irb] Fix help-message (https://github.com/ruby/irb/pull/506)
https://github.com/ruby/irb/commit/a55ace0791
2023-02-15 14:53:33 +00:00
tomoya ishida f313514563 [ruby/irb] Fix colorize backtick symbol
(https://github.com/ruby/irb/pull/508)

https://github.com/ruby/irb/commit/dd7f25cd45

Co-authored-by: Stan Lo <stan001212@gmail.com>
2023-02-12 20:27:32 +00:00
Stan Lo cb9b885e78 [ruby/irb] Store context in RubyLex
Some background for this refactor:

1. Through a RubyLex instance's lifetime, the context passed to its methods
   should be the same.
   Given that `Context` is only initialised in `Irb#initialize`,
   this should be true.

2. When `RubyLex` is initialised, the context object should be accessible.
   This is also true in all 3 of `RubyLex.new`'s invocations.

With the above observations, we should be able to store the context in `RubyLex`
as an instance variable. And doing so will make `RubyLex`'s instance methods
easier to use and maintain.

https://github.com/ruby/irb/commit/5c8d3df2df
2023-01-14 09:19:09 +00:00
Stan Lo 207f8d0027 [ruby/irb] Avoid calling private methods on the main object
(https://github.com/ruby/irb/pull/498)

When the main object is frozen, `IRB` wraps a `SimpleDelegator` around it.
But because `SimpleDelegator` doesn't delegate private methods, methods like
`require_relative` or `const_get` would cause error, which are needed for
lazily loading commands.

This commit works around this limitation by avoiding those private method calls
when setting up command execution.
2023-01-12 11:49:16 +00:00
Stan Lo 019c65828b [ruby/irb] Remove redundant argument defaults from some RubyLex
methods
(https://github.com/ruby/irb/pull/502)

* Remove unnecessary parameter defaults

These methods are always called with tokens specified. So their default
`@tokens` value is never used and is misleading.

* Remove unnecessary context default

* Require tokens for `RubyLex#check_state`
2023-01-12 10:30:17 +00:00
Hiroshi SHIBATA 7e283c585e [ruby/irb] Formatting to header styles
https://github.com/ruby/irb/commit/cef125850d
2023-01-11 22:29:10 +00:00
Hiroshi SHIBATA 128398e7cd [ruby/irb] After Ruby 2.0, coding is always utf-8
https://github.com/ruby/irb/commit/7a94bc4135
2023-01-11 22:29:10 +00:00
Hiroshi SHIBATA c7bb8d67b7 [ruby/irb] Removed Release Version and Revisions for old VCS software
https://github.com/ruby/irb/commit/07fae94862
2023-01-11 22:29:09 +00:00
Stan Lo c693dfd7ef [ruby/irb] Drop unused arguments in `RubyLex`
(https://github.com/ruby/irb/pull/504)

* Simplify `RubyLex#set_prompt`

It's optional argument is never used by any caller.

* Remove the optional `p` argument from `RubyLex#set_input`

The argument is only used in a test case, which can be easily replaced by
a block argument.
2023-01-11 21:26:18 +00:00
Stan Lo 3d6500ee6e [ruby/irb] workspace.rb cleanup
(https://github.com/ruby/irb/pull/489)

* Remove unnecessary Binding#source_location check

`Binding#source_location` was added in 2.6, which is the minimum supported
version now. So this check is no longer necessary.

* Remove unused IRB.delete_caller

This method was added in the earliest version of IRB:

f47808999d

But it's not currently referenced by anything. We can verify this with a
org-wide search result:

https://github.com/search?q=org%3Aruby+delete_caller&type=code
2023-01-04 09:35:57 +00:00
tomoya ishida 34f8ca1714 [ruby/irb] Fix prompt and code mismatch
(https://github.com/ruby/irb/pull/386)

* fix prompt and code mismatch

* Add test for prompt and code mismatch bug

https://github.com/ruby/irb/commit/a5765d8177

Co-authored-by: Stan Lo <stan001212@gmail.com>
2023-01-02 19:25:11 +00:00
Mau Magnaguagno ec7e082906 [ruby/irb] Refactor RubyLex#process_literal_type
(https://github.com/ruby/irb/pull/350)

Simplify part of regex ``[_a-zA-Z0-9]`` with equivalent shorthand ``\w``.
Replace case-when with match ``$1`` or default value ``?"``, making intention more clear.
2022-12-27 17:05:32 +00:00
Hiroshi SHIBATA c09f342d04 [ruby/irb] Fix wrong conf path with XDG_CONFIG_HOME. It should be under the HOME directory, not current directory
https://github.com/ruby/irb/commit/33a5e55ffd
2022-12-27 00:09:12 +00:00
tompng 953d4c22ed [ruby/irb] fix indent depth calculation after heredoc and embdoc
https://github.com/ruby/irb/commit/b7973dd2d2
2022-12-26 13:03:07 -08:00
tompng f20aac5c59 [ruby/irb] fix auto-indent after multiline string
https://github.com/ruby/irb/commit/f65ec49684
2022-12-26 13:03:07 -08:00
Takashi Kokubun b2bf5d237b [ruby/irb] Version 1.6.2
https://github.com/ruby/irb/commit/a8ea9963c6
2022-12-20 09:07:55 -08:00
Takashi Kokubun cf0b413ef8 [ruby/irb] Respect DLEXT to force-load debug.so
(https://github.com/ruby/irb/pull/481)

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2022-12-20 09:07:54 -08:00
Takashi Kokubun a1dba60b5b [ruby/irb] Version 1.6.1
https://github.com/ruby/irb/commit/229476ba76
2022-12-13 18:36:45 +00:00
Stan Lo 223d4448c8 [ruby/irb] `show_doc` command should take non-string argument too
(https://github.com/ruby/irb/pull/478)

Given that `show_doc` already supports syntax like `String#gsub`, it
should be able to take it in non-string form too, like `edit` and
`show_source` do. This ensures users can have a consistent syntax on
argument between different commands.
2022-12-12 17:35:48 +00:00