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

150 Коммитов

Автор SHA1 Сообщение Дата
tomoya ishida 556439613a [ruby/irb] Handle long inspect and control character in prompt
string
(https://github.com/ruby/irb/pull/528)

* Handle long inspect and control characters in prompt string

* Add constants for prompt truncate length, omission and replace pattern

* Simply compare string instead of regexp in prompt truncation test
2023-03-02 13:53:44 +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
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
Takashi Kokubun 5958c305e5 [ruby/irb] Document a full list of commands
(https://github.com/ruby/irb/pull/451)

* Document a full list of commands

* Document debug as well

* Make it less duplicated
2022-11-19 22:14:44 +00:00
Takashi Kokubun 23750c866a [ruby/irb] Update documentation about Autocompletion
(https://github.com/ruby/irb/pull/452)

https://github.com/ruby/irb/commit/e6b4917750
2022-11-19 22:10:09 +00:00
Takashi Kokubun b1cbc883f2 [ruby/irb] Minor fixes on debug command
(https://github.com/ruby/irb/pull/447)

* Minor fixes on debug command

* Update lib/irb/cmd/debug.rb
2022-11-18 17:34:42 +00:00
Stan Lo 00872d120b [ruby/irb] Add debug command (https://github.com/ruby/irb/pull/446)
https://github.com/ruby/irb/commit/30faa13fa3
2022-11-18 09:11:23 +00:00
Takashi Kokubun d8202a52a5 [ruby/irb] Add an option to suppress code_around_binding
(https://github.com/ruby/irb/pull/444)

for debug.gem's `irb` command
2022-11-18 00:47:53 +00:00
st0012 923c1aaed7
Drop Ruby 2.5 support
Because it has reached EOL for more than 1.5 years and it won't be
supported by the next reline version either.
2022-11-17 13:06:32 +09:00
Takashi Kokubun 8fa83fa0b2 [ruby/irb] Transform ls's --grep/-G option to keyword args
(https://github.com/ruby/irb/pull/437)

* Transform ls's --grep/-G option to keyword args

* Make --grep less flexible

* Support -g instead of --grep

* Suppress warnings from symbol aliases
2022-11-10 22:55:15 +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
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
Burdette Lamar 66dfcbed37 [ruby/irb] [DOC] Include updated help message (https://github.com/ruby/irb/pull/377)
* Include updated help message

https://github.com/ruby/irb/commit/ff129f3794
2022-07-12 00:05:15 +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
Peter Zhu 5ca2335802 [ruby/irb] [DOC] Fix formatting in docs
https://github.com/ruby/irb/commit/3ddc89e38c
2022-06-20 22:42:30 +09:00
Kouhei Yanagita e658da9408 [ruby/irb] Fix documents for .irbrc path
https://github.com/ruby/irb/commit/af99c01b0d
2022-05-18 07:12:29 +09:00
aycabta 1855f901c8 [ruby/irb] Check colorize option correctly to clear char attr and don't use it for tests
https://github.com/ruby/irb/commit/de561cafeb
2021-12-21 15:50:32 +09:00
aycabta 093aaeffbc [ruby/irb] Add resetting char attr that I forgot
https://github.com/ruby/irb/commit/b5f953dc33
2021-12-21 15:36:28 +09:00
Kaíque Kandy Koga 0eb1c4ea3a [ruby/irb] Add information about --extra-doc-dir option in the comments
https://github.com/ruby/irb/commit/ac3d4b9e79
2021-12-19 20:26:29 +09:00
Kaíque Kandy Koga 80e2242da6 [ruby/irb] Update descriptions of methods
From Reidline to Reline

Update description used in take_corresponding_syntax_to_kw_do and is_the_in_correspond_to_a_for methods

Use possessive noun correctly

Second element

https://github.com/ruby/irb/commit/4fa9714d6f
2021-10-07 23:55:54 +09:00
aycabta 31332cf469 [ruby/irb] Fix typo of variable
https://github.com/ruby/irb/commit/692eb9b9b5
2021-10-04 09:37:13 +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 5c0636bda4 [ruby/irb] Add a space before left paren
https://github.com/ruby/irb/commit/973bac83ff
2021-09-27 03:23:31 +09:00
aycabta 90afe5f11f [ruby/irb] Move IRB::TOPLEVEL_BINDING from exe/irb to lib/irb/workspace.rb
https://github.com/ruby/irb/commit/e736a77076
2021-09-10 06:37:07 +09:00
aycabta ece4ed0da7 Add --autocomplete / --noautocomplete options 2021-08-30 02:45:13 +09:00
Jeremy Evans 289fd3c801 [ruby/irb] Pass local variables from workspace binding to lexer
This fixes at least an issue where irb will incorrectly assume
code opens a heredoc when it does not, such as this code:

```ruby
s1 = 'testing'
s2 = 'this'
s2 <<s1
p s1
s1
```

Ruby parses the `s2 <<s1` as `s2.<<(s1)`, not as a heredoc, because
`s2` is a local variable in scope.  irb was using ripper without
letting ripper know that `s2` was a local variable, so ripper would
lex it as a heredoc instead of a method call.

Fix the situation by prepending a line at line 0 with all local
variable definitions in scope whenever lexing.  This fixes the
heredoc issue, and potentially other issues that depend on whether
an identifier is a local variable or not.

Fixes [Bug #17530]

https://github.com/ruby/irb/commit/4ed2187f76
2021-07-10 13:44:17 +09:00
Koichi ITO c45f7556b5 [ruby/irb] Fix `Encoding::ConverterNotFoundError`
Follow https://github.com/ruby/irb/pull/237.

This PR fixes the following `Encoding::ConverterNotFoundError`.

```console
% bin/spring stop && bin/rails c
Spring stopped.
Running via Spring preloader in process 58395
Loading development environment (Rails 6.0.3.7)
irb(main):001:0> "こんにちは".do_something
Traceback (most recent call last):
(snip)

    12: from /Users/koic/src/github.com/ruby/irb/lib/irb.rb:547:in `eval_input'
    11: from /Users/koic/src/github.com/ruby/irb/lib/irb/ruby-lex.rb:232:in `each_top_level_statement'
    10: from /Users/koic/src/github.com/ruby/irb/lib/irb/ruby-lex.rb:232:in `catch'
     9: from /Users/koic/src/github.com/ruby/irb/lib/irb/ruby-lex.rb:233:in  `block in each_top_level_statement'
     8: from /Users/koic/src/github.com/ruby/irb/lib/irb/ruby-lex.rb:233:in `loop'
     7: from /Users/koic/src/github.com/ruby/irb/lib/irb/ruby-lex.rb:251:in `block (2 levels) in each_top_level_statement'
     6: from /Users/koic/src/github.com/ruby/irb/lib/irb.rb:548:in `block in eval_input'
     5: from /Users/koic/src/github.com/ruby/irb/lib/irb.rb:758:in `signal_status'
     4: from /Users/koic/src/github.com/ruby/irb/lib/irb.rb:586:in `block (2 levels) in eval_input'
     3: from /Users/koic/src/github.com/ruby/irb/lib/irb.rb:650:in `handle_exception'
     2: from /Users/koic/src/github.com/ruby/irb/lib/irb.rb:601:in `encode_with_invalid_byte_sequence'
     1: from /Users/koic/src/github.com/ruby/irb/lib/irb.rb:601:in `new'
/Users/koic/src/github.com/ruby/irb/lib/irb.rb:601:in `initialize': code
converter not found (UTF-8 to UTF-8) (Encoding::ConverterNotFoundError)
```

First, this patch skips `Encoding::Converter.new` for the same encoding.
170531df19/lib/irb.rb (L601)

Next, this is a talk about the condition for skipping. `IRB.conf[:LC_MESSAGES].encoding`
becomes `"UTF-8"` string when `Reline.encoding_system_needs.name` is set in the below.
170531df19/lib/irb/input-method.rb (L269)

OTOH, `message.encoding` is `Encoding::UTF_8`, so these are compared as a string by this patch.

https://github.com/ruby/irb/commit/6df6e76cfc
2021-05-11 16:17:17 +09:00
aycabta 774cc32b4d [ruby/irb] Treat encodings in exception correctly
https://github.com/ruby/irb/commit/4452adbe04
2021-05-11 09:32:08 +09:00
Koichi Sasada 1ac68bba4e [ruby/irb] SIGINT should raise Interrupt after IRB session
https://github.com/ruby/irb/commit/5832cfe75b
2021-04-02 01:57:44 +09:00
Jeremy Evans dbea0be13d [ruby/irb] Update help message for next context-mode of 4
While here, fixing tab/space issues in help message, and sync
rdoc for IRB class to match the help message.

https://github.com/ruby/irb/commit/ef8e3901cc
2021-02-27 06:51:12 +09:00
Nobuhiro IMAI e80e5a2f89 [ruby/irb] use `RubyLex::TerminateLineInput` appropriately [Bug #17564]
* using the appropriciate exception instead of `break` so that the session
  can be continue after the `irb_source` and `irb_load` commands
* suppress extra new line due to one more `#prompt` call

https://github.com/ruby/irb/commit/bdefaa7cfd
2021-01-27 15:02:05 +09:00
Nobuhiro IMAI d290a02bd7 [ruby/irb] handle repeated exception separately
https://github.com/ruby/irb/commit/fcf6b34bc5
2021-01-18 02:12:53 +09:00
aycabta 6cbb3fd142 [ruby/irb] Fix comment, irb gem supports 2.5.0 or older
https://github.com/ruby/irb/commit/36118015ba
2021-01-08 13:32:10 +09:00
aycabta 111fddd543 [ruby/irb] Fix BACK_TRACE_LIMIT logic
https://github.com/ruby/irb/commit/30dc5d43fe
2021-01-08 13:25:18 +09:00
aycabta 917050220a [ruby/irb] Use Exception#full_message to show backtrace in the correct order
[Bug #17466]

https://github.com/ruby/irb/commit/1c76845cca
2021-01-08 13:25:18 +09:00
Nobuhiro IMAI 4bb683a570 [ruby/irb] fix typo in `IRB::Irb#convert_invalid_byte_sequence`
https://github.com/ruby/irb/commit/d09d3c3d68
2021-01-08 13:25:18 +09:00
aycabta e72a6ed45f [ruby/irb] Escape invalid byte sequence in Exception
This fixes ruby/irb#141.

https://github.com/ruby/irb/commit/0815317d42
2021-01-05 18:05:06 +09:00
aycabta 4131cd05be [ruby/irb] Support arg for measure command
https://github.com/ruby/irb/commit/b43f35d8f3
2020-12-22 23:45:43 +09:00
aycabta 9f08e3c703 [ruby/irb] Add measure command
You can use "measure" command to check performance in IRB like below:

  irb(main):001:0> 3
  => 3
  irb(main):002:0> measure
  TIME is added.
  => nil
  irb(main):003:0> 3
  processing time: 0.000058s
  => 3
  irb(main):004:0> measure :off
  => nil
  irb(main):005:0> 3
  => 3

You can set "measure :on" by "IRB.conf[:MEASURE] = true" in .irbrc, and, also,
set custom performance check method:

  IRB.conf[:MEASURE_PROC][:CUSTOM] = proc { |context, code, line_no, &block|
    time = Time.now
    result = block.()
    now = Time.now
    puts 'custom processing time: %fs' % (Time.now - time) if IRB.conf[:MEASURE]
    result
  }

https://github.com/ruby/irb/commit/3899eaf2e2
2020-12-20 16:23:59 +09:00
aycabta 2d112c346a [ruby/irb] Stop using bang version for #inspect of result
https://github.com/ruby/irb/commit/fc1426d34e
2020-11-22 21:00:11 +09:00
Andrew Kerr ef3c25888e Fix small typo in comment in lib/irb.c 2020-10-22 10:56:35 -07: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 8f9b1902f4 [ruby/irb] Omit output if first line of multiline is too long
https://github.com/ruby/irb/commit/0feeae38c5
2020-09-14 02:13:18 +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 d32229e338 [ruby/irb] Prefer require_relative to load the files in this library
https://github.com/ruby/irb/commit/0ac3bc7296
2020-08-18 14:38:01 +09:00
Nobuyoshi Nakada bc646e6715
[DOC] get rid of parsing as TIDYLINK unintentionally 2020-04-07 13:59:38 +09:00
aycabta 22477128cd [ruby/irb] Suppress crashing when EncodingError has occurred without lineno
https://github.com/ruby/irb/commit/13572d8cdc
2020-03-26 17:41:21 +09:00