(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
(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
(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
(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.
(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`.
(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.
(https://github.com/ruby/irb/pull/449)
* Seamlessly integrate a few debug commands
* Improve the break command support
* Utilize skip_src option if available
* Add step and delete commands
* Write end-to-end tests for each debugger command
* Add documentation
* Add backtrace, info, catch commands
https://github.com/ruby/irb/commit/976100c1c2
Based on this commit: 93f87ec653
It appears that the maintainer @aycabta wanted to deprecate any `USE_*LINE` configs in favor of
`USE_MULTILINE`. So we should deprecate `USE_RELINE` as well.
https://github.com/ruby/irb/commit/478f19f3ae
* Use local_variables for colorize, code_block_open check, nesting_level and assignment_expression check
* Check if expression is an assignment BEFORE evaluating it. evaluate might define new localvars and change result of assignment_expression?
* Add local_variables dependent code test
* pend local variable dependent test on truffleruby
code_block_open is not working on truffleruby
* Always pass context to RubyLex#lex
* Rename local_variable_assign_code generator method name
* Add assignment expression truncate test
* Add Context#local_variables and make generate_local_variables_assign_code more simple
* Update lib/irb/input-method.rb
Co-authored-by: Stan Lo <stan001212@gmail.com>
* Add a comment why assignment expression check should be done before evaluate
https://github.com/ruby/irb/commit/c8b3877281
Co-authored-by: Stan Lo <stan001212@gmail.com>
Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
Deprecates IDB::ReidlineInputMethod and USE_REIDLINE in favor of
IRB::RelineInputMethod and USE_RELINE. The Input method uses Reline to
read input from the console, so it can be named directly after the
Reline library like other inputs methods are (Readline, Stdio, etc.).
https://github.com/ruby/irb/commit/5bcade7130
Also add --script option to turn the option back on.
Previously there wasn't a way to get an interactive IRB session
and access arguments provided on the command line.
Additionally, handle `-` as script as stdin. In Unix-like tools, `-`
means to take standard input instead of a file. This doesn't
result in exactly the same output for:
```
echo 'p ARGV' > args.rb; irb args.rb a b c
```
and
```
echo 'p ARGV' | irb - a b c
```
Due to how irb handles whether stdin is a tty.
However, this change allows use of `-` as a argument, instead of
giving an unrecognized switch error. This required some small
changes to context.rb (to handle `-` as standard input) and
input-method.rb (to have FileInputMethod accept IO arguments in
addition to strings).
Implements [Feature #15371]
https://github.com/ruby/irb/commit/4192683ba2
* Use colorable: argument as the only coloring control
* Centalize color controling logic at Color.colorable?
There are 2 requirements for coloring output:
1. It's supported on the platform
2. The user wants it: `IRB.conf[:USE_COLORIZE] == true`
Right now we check 1 and 2 separately whenever we colorize things.
But it's error-prone because while 1 is the default of `colorable`
parameter, 2 always need to manually checked. When 2 is overlooked, it
causes issues like https://github.com/ruby/irb/pull/362
And there's 0 case where we may want to colorize even when the user
disables it. So I think we should merge 2 into `Color.colorable?` so it
can be automatically picked up.
* Add tests for all inspect modes
* Simplify inspectors' coloring logic
* Replace use_colorize? with Color.colorable?
* Remove Context#use_colorize cause it's redundant
https://github.com/ruby/irb/commit/1c53023ac4
Omit the results evaluated at assignment if they are too long.
The behavior of ECHO_ON_ASSIGNMENT being on by default is hard to understand,
so I change it to off by default. Instead, we turn OMIT_ON_ASSIGNMENT on by
default. The result is displayed on assignment, but it will always be short
and within one line of the screen.
https://github.com/ruby/irb/commit/c5ea79d5ce
* lib/irb/context.rb (IRB::Context#evaluate): separate the code
from wrapping lines to propagate the given exception, not to show
the wrapping lines when SyntaxError.