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

983 Коммитов

Автор SHA1 Сообщение Дата
tomoya ishida f53209f023 [ruby/irb] Cache RDoc::RI::Driver.new
(https://github.com/ruby/irb/pull/911)

* Cache RDoc::RI::Driver.new to improve performance and to avoid flaky test

* Insert sleep to fix flaky rendering test that renders document dialog

https://github.com/ruby/irb/commit/da84e6cb56
2024-03-25 11:48:11 +00:00
OKURA Masafumi e6487a9263 [ruby/irb] docs(help): Add latest options to ja help message
(https://github.com/ruby/irb/pull/903)

https://github.com/ruby/irb/commit/3c6d452495
2024-03-18 02:37:42 +00:00
tomoya ishida bda5b09937 [ruby/irb] Fix irb_history saved to current directory
(https://github.com/ruby/irb/pull/901)

* Always save irb_history in HOME or XDG_CONFIG_HOME

Also split irbrc search logic from irb_history search logic as a refactor

* Remove IRB.conf[:RC_NAME_GENERATOR] because it's not configurable

This conf is used to specify which irbrc to load. Need to configure before irbrc is loaded, so it's actually not configurable.
This conf is also used for history file search, but it is configurable by conf[:HISTORY_FILE].

* remove rc_file_test because it is tested with rc_files, remove useless test setup

* Make internal irbrc searching method private

https://github.com/ruby/irb/commit/11d03a6ff7
2024-03-16 15:20:03 +00:00
Stan Lo 137b52a881 [ruby/irb] Use markdown format for docs
(https://github.com/ruby/irb/pull/890)

* Convert irb.rb's document into markdown format

* Hide should-be-private top-level methods from docs

* Skip xmp.rb's docs

* Declare lib/irb.rb's markup do it works in ruby/ruby too

* Ignore docs folder

https://github.com/ruby/irb/commit/e9a175e06b
2024-03-16 13:51:07 +00:00
Go d10afe0357 [ruby/irb] Rescue from exceptions raised by #name
(https://github.com/ruby/irb/pull/899)

* Rescue from exceptions raised by #name

Irb might terminate if the class overwrites `name` and raise errors. This commit rescue irb from termination.

* fix for other unknown patterns

https://github.com/ruby/irb/commit/35b87cf893
2024-03-14 15:41:03 +00:00
hogelog 3822ca9884 [ruby/irb] Add disable_irb command to disable debug of binding.irb
(https://github.com/ruby/irb/pull/898)

* Add disable_irb command to disable debug of binding.irb

* disable_irb doesn't override Kernel.exit

Kernel.exit call is removed because disable_irb does not override Kernel.exit
and workaround to https://bugs.ruby-lang.org/issues/18234 is not needed.

https://github.com/ruby/irb/commit/29901e4f21
2024-03-14 15:40:27 +00:00
alpaca-tc e8f796e954 [ruby/irb] rdoc version lock is required
(https://github.com/ruby/irb/pull/897)

Some features of irb do not work properly when using the old rdoc.
I have compared several major versions and found that it works as intended from 4.0.0.

This problem occurs when there is a Gemfile.lock is installed with the old rdoc.
I don't know why this Gemfile.lock installs an older rdoc than the ruby bundled rdoc,
but specifying the version in the gemspec will at least prevent the problem.

NOTE: ruby/irb#704 problem does not occur with this change.

The following is test code.

```
 ### Usage: ruby __FILE__.rb
 # # input RDoc and Tab
 # >> RDoc<Tab>
 #
 ### Expect: Display document of RDoc
 ### Actual: <internal:marshal>:34:in `load': instance of RDoc::Constant needs to have method `marshal_load' (TypeError)
require "bundler/inline"

gemfile(true) do
  source "https://rubygems.org"

  git_source(:github) { |repo| "https://github.com/#{repo}.git" }
  gem 'irb'
  # gem 'rdoc', '~> 4.0.0'
  gem 'rdoc', '~> 3.12.0'
end

require 'rdoc'
require 'irb'

IRB.start
```

https://github.com/ruby/irb/commit/1a1fbba020
2024-03-08 09:23:40 +00:00
Stan Lo 9fcb2bd5c0 [ruby/irb] Bump version to v1.12.0
(https://github.com/ruby/irb/pull/895)

https://github.com/ruby/irb/commit/a79e84a692
2024-03-07 02:14:44 +00:00
Haroon Ahmed 8f6113a91e [ruby/irb] Add the ability to fetch and load multiple irb files.
(https://github.com/ruby/irb/pull/859)

This allows hierarchy when loading rc files for example both files below
are loaded;

project/.irbrc
~/.irbrc

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

Co-authored-by: Stan Lo <stan001212@gmail.com>
2024-03-05 16:07:45 +00:00
Stan Lo 57ca5960ad [ruby/irb] Restructure workspace management
(https://github.com/ruby/irb/pull/888)

* Remove dead irb_level method

* Restructure workspace management

Currently, workspace is an attribute of IRB::Context in most use cases.
But when some workspace commands are used, like `pushws` or `popws`, a
workspace will be created and used along side with the original workspace
attribute.

This complexity is not necessary and will prevent us from expanding
multi-workspace support in the future.

So this commit introduces a @workspace_stack ivar to IRB::Context so IRB
can have a more natural way to manage workspaces.

* Fix pushws without args

* Always display workspace stack after related commands are used

https://github.com/ruby/irb/commit/61560b99b3
2024-03-01 15:51:29 +00:00
Stan Lo c976cb52a2 [ruby/irb] Add help messages to `show_source` and `show_doc`
commands
(https://github.com/ruby/irb/pull/887)

* Add help message to the show_source command

* Add help message to the show_doc command

https://github.com/ruby/irb/commit/06f43aadb3
2024-02-25 15:22:33 +00:00
Stan Lo 898f30f8bd [ruby/irb] Refactor IRB::Context#prompting
(https://github.com/ruby/irb/pull/889)

https://github.com/ruby/irb/commit/7b323ee514
2024-02-25 15:21:00 +00:00
tomoya ishida ea2fb7460e [ruby/irb] Remove useless loaded file check
(https://github.com/ruby/irb/pull/885)

https://github.com/ruby/irb/commit/f6d489658e
2024-02-23 13:11:20 +00:00
tomoya ishida 598b03648f [ruby/irb] Remove remaining `frozen_string_literal: false` in lib/
(https://github.com/ruby/irb/pull/883)

https://github.com/ruby/irb/commit/4bfdb23ae6
2024-02-23 12:32:50 +00:00
Stan Lo 4831bb5bab [ruby/irb] Turn on frozen literal in files
(https://github.com/ruby/irb/pull/881)

https://github.com/ruby/irb/commit/83d90550c2
2024-02-23 10:53:53 +00:00
Stan Lo 37dde6e2f8 [ruby/irb] Unroll extension method generation
(https://github.com/ruby/irb/pull/882)

* Unroll extension method generation

Given we only have 2 remaining extension setter methods, both of which
only take 1 argument and don't have any alias, the current method generation
logic is overly complicated.

This commit simplifies the method generation logic by simply defining
the methods directly in the `IRB::Context` class.

* Fix use_loader extension

https://github.com/ruby/irb/commit/67eba5401b
2024-02-23 10:02:19 +00:00
tomoya ishida 88431c47ba [ruby/irb] Delete IRB::NotImplementedError
(https://github.com/ruby/irb/pull/878)

https://github.com/ruby/irb/commit/6751778948
2024-02-22 13:16:46 +00:00
Stan Lo 7e577e150a [ruby/irb] Fix `irb:rdbg` for ruby head
(https://github.com/ruby/irb/pull/876)

* Update binding.irb check for Ruby head

With https://github.com/ruby/ruby/pull/9605, backtrace in Ruby head
now has a new format. This commit updates the check for binding.irb
to work with Ruby head.

* Do not include a backtick in error messages and backtraces

[Feature #16495]

---------

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

Co-authored-by: Yusuke Endoh <mame@ruby-lang.org>
2024-02-19 11:01:30 +09:00
Stan Lo 07c774e85c [ruby/irb] Revamp `help` command
(https://github.com/ruby/irb/pull/877)

* Make help command display help for individual commands

Usage: `help [command]`

If the command is not specified, it will display a list of all available commands.

If the command is specified, it will display the banner OR description of the command.

If the command is not found, it will display a message saying that the command is not found.

* Rename test/irb/cmd to test/irb/command

* Add banner to edit and ls commands

* Promote help command in the help message

1. Make `show_cmds` an alias of `help` so it's not displayed in the help message
2. Update description of the help command to reflect `help <command>` syntax

* Rename banner to help_message

https://github.com/ruby/irb/commit/43a2c99f3f
2024-02-18 18:21:08 +00:00
Stan Lo f5801e2bf4 [ruby/irb] Standardize command related names
(https://github.com/ruby/irb/pull/873)

* Replace ExtendCommand with Command and standardize command related names

1. Rename lib/irb/extend-command.rb to lib/irb/command.rb
2. Rename lib/irb/cmd/*.rb to lib/irb/command/*.rb
3. Rename test/irb/test_cmd.rb to test/irb/test_command.rb
4. Rename ExtendCommand to Command

* Alias ExtendCommand to Command and deprecate it

* Rename Command::Nop to Command::Base

* Not deprecate old constants just yet

* Add lib/irb/cmd/nop.rb back

https://github.com/ruby/irb/commit/462c1284af
2024-02-16 16:47:36 +00:00
Stan Lo b315826377 [ruby/irb] Support repeating debugger input by passing empty input
to it
(https://github.com/ruby/irb/pull/856)

* Test IRB's behaviour with empty input

* Handle empty input and pass it to debugger

Since `rdbg` accepts empty input to repeat the previous command, IRB
should take empty input in `irb:rdbg` sessions and pass them to the
debugger.

Currently, IRB simply ignores empty input and does nothing. This commit
creates `EmptyInput` to represent empty input so it can fit into the
current IRB's input processing flow in `Irb#eval_input`.

https://github.com/ruby/irb/commit/0e9db419be
2024-02-16 16:12:54 +00:00
Stan Lo c84581f1d9 [ruby/irb] Repurpose the help command to display the help message
(https://github.com/ruby/irb/pull/872)

See #787 for more details.

https://github.com/ruby/irb/commit/d9192d92d0
2024-02-14 13:47:45 +00:00
tomoya ishida d0412599e0 [ruby/irb] Improve constant lookup in SourceFinder
(https://github.com/ruby/irb/pull/871)

https://github.com/ruby/irb/commit/87c279ccf2
2024-02-14 13:46:49 +00:00
Stan Lo 2f0f95235a [ruby/irb] Fix SourceFinder's constant evaluation issue
(https://github.com/ruby/irb/pull/869)

Currently, if the signature's constant part is not defined, a NameError
would be raised.

```
irb(main):001> show_source Foo
(eval):1:in `<top (required)>': uninitialized constant Foo (NameError)

Foo
^^^
        from (irb):1:in `<main>'
```

This commit fixes the issue and simplifies the `edit` command's implementation.

https://github.com/ruby/irb/commit/8c16e029d1
2024-02-13 13:36:32 +00:00
Stan Lo ec26786b1a [ruby/irb] Refactor eval_path and `SourceFinder::Source`
(https://github.com/ruby/irb/pull/870)

* Assign `@eval_path` through `irb_path=` method

This simplifies the original caching logic for the `eval_path` method
and makes it easier to understand.

* Refactor SourceFinder::Source

https://github.com/ruby/irb/commit/c63e4c4035
2024-02-13 13:33:36 +00:00
tomoya ishida 7af97dc71f [ruby/irb] Powerup show_source by enabling RubyVM.keep_script_lines
(https://github.com/ruby/irb/pull/862)

* Powerup show_source by enabling RubyVM.keep_script_lines

* Add file_content field to avoid reading file twice while show_source

* Change path passed to eval, don't change irb_path.

* Encapsulate source coloring logic and binary file check insode class Source

* Add edit command testcase when irb_path does not exist

* Memoize irb_path existence to reduce file existence check calculating eval_path

https://github.com/ruby/irb/commit/239683a937
2024-02-12 18:38:30 +00:00
tomoya ishida 06995eb45b [ruby/irb] Fix exit! command warning and method behavior
(https://github.com/ruby/irb/pull/868)

* Fix exit! command warning and method behavior

* Remove arg(0) from Kernel.exit and Kernel.exit!

https://github.com/ruby/irb/commit/372bc59bf5
2024-02-12 11:28:54 +00:00
Stan Lo 5c4657f883 [ruby/irb] Polish the exit! command and its tests
(https://github.com/ruby/irb/pull/867)

* Remove IRB.irb_exit! method

It's not necessary to introduce a new method just for the exit! command
at this moment.

* Rename ExitForcedAction to ForceExit

* Move force exit tests to a dedicated file

* Fix nested history saving with exit! command

Because we switched to use `Kernel#exit` instead of `exit!`, the outer
session's ensure block in `Irb#run` will be run, which will save the
history. This means the separate check to save history when force exiting
is no longer necessary.

* execute_lines helper should also capture IRB setup's output

This prevents setup warnings from being printed to test output
while allowing those output to be tested.

* Update readme

https://github.com/ruby/irb/commit/899d10ade1
2024-02-11 05:17:40 +00:00
Ignacio Chiazzo Cardarello 429eeb09f2 [ruby/irb] Introduce exit! command
(https://github.com/ruby/irb/pull/851)

* Added failing test for when writing history on exit

* Save history on exit

* Exit early when calling Kernel.exit

* use status 0 for kernel.exit

* Added test for nested sessions

* Update lib/irb.rb

---------

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

Co-authored-by: Stan Lo <stan001212@gmail.com>
2024-02-10 22:07:53 +00:00
Stan Lo 0b7f516834 [ruby/irb] Bump version to v1.11.2
(https://github.com/ruby/irb/pull/865)

https://github.com/ruby/irb/commit/afe1f459cc
2024-02-07 16:57:33 +00:00
Stan Lo 5f4245e74b [ruby/irb] Polish tracer integration and tests
(https://github.com/ruby/irb/pull/864)

* Remove useless ivar

* Simplify tracer test setup

* Treat tracer like a normal development dependency

* Only require ext/tracer when value is truthy

* Make tracer integration skip IRB traces

https://github.com/ruby/irb/commit/a97a4129a7
2024-02-07 14:59:10 +00:00
Nuno Silva 300dee1fe8 [ruby/irb] Fix usage of tracer gem and add tests
(https://github.com/ruby/irb/pull/857)

The new tests are skipped when ruby below 3.1, as it was a default gem on it, and in a version we do not support.

This also move definition of `use_tracer` to module Context instead of monkey patch.

https://github.com/ruby/irb/commit/08834fbd5f
2024-02-06 16:46:50 +00:00
Stan Lo 5d646fa136 [ruby/irb] Require pathname (https://github.com/ruby/irb/pull/860)
https://github.com/ruby/irb/commit/0ab96ed426
2024-02-02 22:25:33 +00:00
Ignacio Chiazzo Cardarello aa780a678e [ruby/irb] Add a warning for when the history path doesn't exist
(https://github.com/ruby/irb/pull/852)

* Add a warning for when the history path doesn't exist

* warn when the directory does not exist

* added test for when the history_file does not exist

* Update lib/irb/history.rb

---------

https://github.com/ruby/irb/commit/9e6fa67212

Co-authored-by: Stan Lo <stan001212@gmail.com>
2024-02-02 21:58:22 +00:00
Stan Lo ef427123ad [ruby/irb] Add rubocop with a few basic styling rules
(https://github.com/ruby/irb/pull/849)

* Use rubocop to enforce a few styling rules

* Add a CI job for linting

https://github.com/ruby/irb/commit/4f60cd88bb
2024-02-01 17:46:02 +00:00
Stan Lo f36c61d27f [ruby/irb] Reset history counter even when @loaded_history_lines is
not defined
(https://github.com/ruby/irb/pull/853)

The issue (https://github.com/ruby/debug/issues/1064) is caused by a
combination of factors:

1. When user starts an IRB session without a history file, the
   `@loaded_history_lines` ivar is not defined.
2. If the user then starts the `irb:rdbg` session, the history counter
   is not set, because the `@loaded_history_lines` is not defined.
3. Because `irb:rdbg` saves the history before passing Ruby expression
   to the debugger, it saves the history with duplicated lines. The number
   grows in exponential order.
4. When the user exits the `irb:rdbg` session, the history file could be
   bloated with duplicated lines.

This commit fixes the issue by resetting the history counter even when
`@loaded_history_lines` is not defined.

https://github.com/ruby/irb/commit/4afc98c258
2024-02-01 16:19:07 +00:00
Nuno Silva 1236a74023 [ruby/irb] Skip re-setup when creating a child session
(https://github.com/ruby/irb/pull/850)

https://github.com/ruby/irb/commit/06b2d00dd3
2024-02-01 12:12:06 +00:00
tomoya ishida fd44b42fb3 [ruby/irb] Fix undef and alias indent
(https://github.com/ruby/irb/pull/838)

https://github.com/ruby/irb/commit/a641746b18
2024-01-30 12:55:47 +00:00
ydah 0334115628 [ruby/irb] Synatx ==> Syntax
https://github.com/ruby/irb/commit/2ffacaa031
2024-01-25 09:58:17 +00:00
ydah fd9b968569 [ruby/irb] recever ==> receiver
https://github.com/ruby/irb/commit/dbd0e368c4
2024-01-25 09:58:15 +00:00
ydah 6580a95f8d [ruby/irb] inifinity ==> infinity
https://github.com/ruby/irb/commit/78dea58000
2024-01-25 09:58:15 +00:00
Stan Lo b2ec4308d6
[ruby/irb] Bump version to v1.11.1
(https://github.com/ruby/irb/pull/837)

https://github.com/ruby/irb/commit/f052097c4b
2024-01-19 10:49:12 +09:00
Stan Lo 8f4eda5092 [ruby/irb] Make SourceFinder ignore binary sources
(https://github.com/ruby/irb/pull/836)

https://github.com/ruby/irb/commit/73b35bb7f4
2024-01-08 12:42:39 +00:00
Stan Lo 4bdfc9070c [ruby/irb] Refactor exit command
(https://github.com/ruby/irb/pull/835)

* Remove unnecessary code from the exit command's implementation

1. The parameters of `IRB.irb_exit` were never used. But there are some
   libraries seem to call it with arguments + it's declared on the top-level
   IRB constant. So I changed the params to anonymous splat instead of removing them.
2. `Context#exit` was completely unnecessary as `IRB.irb_exit` doesn't use
   the `@irb` instance it passes. And since it's (or should be treated as)
   a private method, I simply removed it.
3. The `exit` command doesn't use the status argument it receives at all.
   But to avoid raising errors on usages like `exit 1`, I changed the argument to
   anonymous splat instead removing it.

* Make exit an actual command

* Update readme

https://github.com/ruby/irb/commit/452b543a65
2024-01-06 17:15:16 +00:00
Stan Lo 3dac27897e [ruby/irb] Require Reline v0.4.2+
(https://github.com/ruby/irb/pull/834)

https://github.com/ruby/irb/commit/eff8d0d46a
2024-01-06 12:16:12 +00:00
Stan Lo 66e0d92de5 [ruby/irb] Avoid completing empty input
(https://github.com/ruby/irb/pull/832)

The candidate list for empty input is all methods + all variables +
all constants + all keywords. It's a long list that is not useful.

https://github.com/ruby/irb/commit/812dc2df7b
2024-01-03 13:47:51 +00:00
Stan Lo 676748abca [ruby/irb] Make show_source resolve top-level constant names
(https://github.com/ruby/irb/pull/831)

https://github.com/ruby/irb/commit/5843616c78
2024-01-01 17:40:38 +00:00
tomoya ishida c0e3c3b6fe [ruby/irb] Fix display_document params in noautocomplete mode
(https://github.com/ruby/irb/pull/826)

* Fix display_document params in noautocomplete mode

* Fix wrong preposing and target order in display_document

The fixed wrong-ordered value is not used in RegexpCompletor, so this change does not affect the test.

https://github.com/ruby/irb/commit/08208adb5e
2024-01-01 13:57:15 +00:00
Stan Lo 31959f1f13 [ruby/irb] Bump version to v1.11.0
(https://github.com/ruby/irb/pull/818)

https://github.com/ruby/irb/commit/7421359b92
2023-12-20 19:11:02 +09:00
Stan Lo 2793a30b69 [ruby/irb] Warn users about errors in loading RC files
(https://github.com/ruby/irb/pull/817)

1. Because `IRB.rc_file` always generates an rc file name, even if the
   file doesn't exist, we should check the file exists before trying to
   load it.
2. If any type of errors occur while loading the rc file, we should
   warn the user about it.

https://github.com/ruby/irb/commit/37ffdc6b19
2023-12-20 19:11:01 +09:00
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