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

89 Коммитов

Автор SHA1 Сообщение Дата
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 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 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 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 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 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
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
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 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
Takashi Kokubun c9fbc779a6 [ruby/irb] Add commands to start and use the debugger
(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
2022-11-21 08:46:27 +00:00
st0012 aecb7f6efc [ruby/irb] Deprecate USE_RELINE and USE_REIDLINE
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
2022-11-15 10:08:30 +00:00
Takashi Kokubun 9001e53e68 [ruby/irb] Support non-string input in show_source
(https://github.com/ruby/irb/pull/430)

* Support non-string input in show_source

* Test show_source as a method
2022-11-07 17:29:28 +00:00
Takashi Kokubun a13836e70d [ruby/irb] Allow non-identifier aliases like Pry's @ and $
(https://github.com/ruby/irb/pull/426)

* Allow non-identifier aliases

* Move the configuration to IRB.conf

* Avoid abusing method lookup for symbol aliases

* Add more alias tests

* A small optimization

* Assume non-nil Context

* Load IRB.conf earlier

https://github.com/ruby/irb/commit/e23db5132e
2022-11-03 22:09:55 +00:00
tomoya ishida a09f764ce5 [ruby/irb] Always use local variables in current context to parse code (https://github.com/ruby/irb/pull/397)
* 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>
2022-10-18 05:44:07 +00:00
Hiroshi SHIBATA 2f6a263787 [ruby/irb] Use USE_REIDLINE for backword compatibility
https://github.com/ruby/irb/commit/e58a3c1b39
2022-10-05 18:59:31 +09:00
Gannon McGibbon 19e4a4c624 [ruby/irb] Rename IDB::ReidlineInputMethod to IRB::RelineInputMethod
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
2022-10-05 17:14:19 +09:00
st0012 b97e909ef4 [ruby/irb] Remove unnecessary Thread presence check
They were introduced around 20 years ago, when Thread is not yet
stabilized. So we don't need them anymore.

https://github.com/ruby/irb/commit/4c75e03b2b
2022-10-03 07:00:53 +09:00
Jeremy Evans b07db96744 [ruby/irb] Support --noscript option to not use first non-option argument as script
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
2022-09-17 02:25:26 +09:00
Stan Lo 44c1316293 [ruby/irb] Centralize coloring control (https://github.com/ruby/irb/pull/374)
* 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
2022-06-28 22:30:42 +09:00
aycabta 866a09dd9e [ruby/irb] Add --extra-doc-dir option to show doc dialog
https://github.com/ruby/irb/commit/3f79cb506f
2021-10-11 21:12:57 +09:00
aycabta dcaaf79ca0 [ruby/irb] Add periods to doc
https://github.com/ruby/irb/commit/6330601629
2021-10-11 20:34:18 +09:00
aycabta 340fabca2c [ruby/irb] Set default return_format
https://github.com/ruby/irb/commit/7ee15bc668
2021-10-11 15:39:48 +09:00
Jeremy Evans 896626fa02 [ruby/irb] Make IRB::Context#exit call super if UncaughtThrowError
Fixes calling exit after binding.irb.

Fixes [Bug #18234]

https://github.com/ruby/irb/commit/4ea8d376f2
2021-10-07 23:53:58 +09:00
aycabta 00cfafc0f5 [ruby/irb] Add doc about "echo on assignment"
https://github.com/ruby/irb/commit/5af637b3c1
2021-09-27 03:23:48 +09:00
aycabta 51773bed10 [ruby/irb] Add blank lines to sample code in doc for readability
https://github.com/ruby/irb/commit/123b7e53ee
2021-09-27 03:23:41 +09:00
aycabta 2ae64bf6b9 [ruby/irb] Fix sample code in doc
https://github.com/ruby/irb/commit/642adbe968
2021-09-27 03:23:37 +09:00
aycabta ece4ed0da7 Add --autocomplete / --noautocomplete options 2021-08-30 02:45:13 +09:00
aycabta 555ea83344 [ruby/irb] Drop OMIT_ON_ASSIGNMENT and add :truncate option for ECHO_ON_ASSIGNMENT
https://github.com/ruby/irb/commit/4c89b0775b
2020-09-19 05:13:08 +09:00
aycabta e468d9f49c [ruby/irb] Add OMIT_ON_ASSIGNMENT
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
2020-09-14 02:13:11 +09:00
Nobuyoshi Nakada bc646e6715
[DOC] get rid of parsing as TIDYLINK unintentionally 2020-04-07 13:59:38 +09:00
Kenta Murata 51a8055d7d [ruby/irb] Add newline_before_multiline_output
https://github.com/ruby/irb/commit/9eb1801a66
2020-01-21 09:51:16 +09:00
aycabta 0e528ae9cb [ruby/irb] Remove warning message to bundle on Ruby 2.7.0
https://github.com/ruby/irb/commit/d9a7844f50
2019-12-24 09:56:40 +09:00
Takashi Kokubun 1fe31737d8
Slightly fix the warning message [ci skip]
I'm not sure, but maybe it was gramatically incorrect?
2019-11-26 01:20:29 -08:00
Takashi Kokubun 958641d991
Suggest an alternative to suppress the irb warning 2019-11-26 01:18:07 -08:00
aycabta eee70b41d4 Add a warning message and --legacy of an alias of --singleline 2019-11-21 02:44:35 +09:00
aycabta 91bf3b7a77 Use singleline/multiline instead of readline/reidline 2019-11-21 02:44:35 +09:00
Jeremy Evans 1fb4584825 Remove unsused output_method argument
Fixes Ruby Bug 9876.
2019-10-24 23:47:50 +09:00
Steven Willis 9d2fed2ccd Don't echo results of assignment expressions 2019-08-16 06:02:45 +09:00
aycabta 43b52ac0a5 Revert "Don't echo results of assignment expressions"
This reverts commit 1ee88c51b3.
2019-08-06 20:28:48 +09:00
Steven Willis 1ee88c51b3 Don't echo results of assignment expressions 2019-08-06 20:15:07 +09:00
aycabta 6d57369105 Auto indent in IRB is enabled by default 2019-07-15 01:07:37 +09:00
Nobuyoshi Nakada 0aa9b003de
context.rb: hide wrapping lines
* 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.
2019-05-27 11:05:51 +09:00
aycabta 260235ce87 Use Reline as Reidline multiline editor in IRB 2019-05-25 02:16:19 +09:00
Takashi Kokubun 32ed85f601
Copy config to make IRB::Context#use_colorize? functional
on initialize

This fixes https://github.com/ruby/ruby/pull/2188
2019-05-21 04:32:17 -07:00
aycabta 3a9008b984 Add --colorize and --nocolorize options to IRB 2019-05-21 08:57:21 +09:00
aycabta 94b740b249 Use Ripper for IRB
The debug option of IRB is deleted because it's just for IRB's pure Ruby
parser.
2019-04-30 14:40:06 +09:00
Nobuyoshi Nakada f4f66bd11c
Revert "IRB is improved with Reline and RDoc, take 2"
Accidentally merged when 89271d4a37
"Adjusted indents".
2019-04-23 21:55:29 +09:00
aycabta f2cd4f4cd0
IRB is improved with Reline and RDoc, take 2 2019-04-23 20:08:02 +09:00
aycabta 51cec00953 Revert "IRB is improved with Reline and RDoc"
This reverts commit 7f273ac6d0.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-21 09:13:49 +00:00