aboutsummaryrefslogtreecommitdiffstats
path: root/lib/irb.rb
Commit message (Collapse)AuthorAgeFilesLines
* [ruby/irb] Refactor RubyLex's input/io methodsStan Lo2023-05-181-2/+2
| | | | | | | | | (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`.
* [ruby/irb] Drop Ruby 2.6 supportStan Lo2023-04-051-1/+0
| | | | | | | | | | | | | | (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
* [ruby/irb] Remove dead code (https://github.com/ruby/irb/pull/554)Stan Lo2023-04-021-10/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Remove unused ATTR_TTY and ATTR_PLAIN constants They were added in https://github.com/ruby/irb/commit/d7d26b51bf47a52e4e2339e2ad509ace74f0e4c7 But the references were removed in https://github.com/ruby/irb/commit/1c76845cca59635bb0cf386ced721e34b25d7410 Co-authored-by: Alexandre Terrasa <alexandre.terrasa@shopify.com> * Remove unused MethodExtender module It was added in https://github.com/ruby/irb/commit/6cc5d718d7045952ef61d504d624f7e70ce828be 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 https://github.com/ruby/irb/commit/aaf4eb4e9830ae71240ca5d2047c5e3ad20a4044 Co-authored-by: Alexandre Terrasa <alexandre.terrasa@shopify.com> * Remove unused InputCompletor.ignored_modules It was added in https://github.com/ruby/irb/commit/88311ce3c84251e6f420246cd14efc96e00888be but the reference was removed in https://github.com/ruby/irb/commit/78c74d24254145a39c4d30168dbcd87dbbbc66dc * Remove unused TracerLoadError constant This constant was added in https://github.com/ruby/irb/commit/cb50fa3738121e4d829cb05b4bcb0d5fb43760c5 but never referenced. --------- https://github.com/ruby/irb/commit/7de0234325 Co-authored-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
* [ruby/irb] Handle long inspect and control character in prompttomoya ishida2023-03-021-2/+15
| | | | | | | | | | | 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
* [ruby/irb] Store context in RubyLexStan Lo2023-01-141-4/+4
| | | | | | | | | | | | | | | | | | 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
* [ruby/irb] Formatting to header stylesHiroshi SHIBATA2023-01-111-4/+1
| | | | https://github.com/ruby/irb/commit/cef125850d
* [ruby/irb] Removed Release Version and Revisions for old VCS softwareHiroshi SHIBATA2023-01-111-2/+0
| | | | https://github.com/ruby/irb/commit/07fae94862
* [ruby/irb] Add commands to start and use the debuggerTakashi Kokubun2022-11-211-4/+2
| | | | | | | | | | | | | | | | | | | | (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
* [ruby/irb] Document a full list of commandsTakashi Kokubun2022-11-191-0/+44
| | | | | | | | | (https://github.com/ruby/irb/pull/451) * Document a full list of commands * Document debug as well * Make it less duplicated
* [ruby/irb] Update documentation about AutocompletionTakashi Kokubun2022-11-191-2/+2
| | | | | | (https://github.com/ruby/irb/pull/452) https://github.com/ruby/irb/commit/e6b4917750
* [ruby/irb] Minor fixes on debug commandTakashi Kokubun2022-11-181-5/+4
| | | | | | | (https://github.com/ruby/irb/pull/447) * Minor fixes on debug command * Update lib/irb/cmd/debug.rb
* [ruby/irb] Add debug command (https://github.com/ruby/irb/pull/446)Stan Lo2022-11-181-0/+13
| | | | https://github.com/ruby/irb/commit/30faa13fa3
* [ruby/irb] Add an option to suppress code_around_bindingTakashi Kokubun2022-11-181-2/+2
| | | | | (https://github.com/ruby/irb/pull/444) for debug.gem's `irb` command
* Drop Ruby 2.5 supportst00122022-11-171-5/+1
| | | | | Because it has reached EOL for more than 1.5 years and it won't be supported by the next reline version either.
* [ruby/irb] Transform ls's --grep/-G option to keyword argsTakashi Kokubun2022-11-101-0/+1
| | | | | | | | | | | (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
* [ruby/irb] Allow non-identifier aliases like Pry's @ and $Takashi Kokubun2022-11-031-0/+3
| | | | | | | | | | | | | | | | | | | | (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
* [ruby/irb] Always use local variables in current context to parse code ↵tomoya ishida2022-10-181-4/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (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>
* [ruby/irb] Remove unnecessary Thread presence checkst00122022-10-031-5/+1
| | | | | | | 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
* [ruby/irb] [DOC] Include updated help message ↵Burdette Lamar2022-07-121-48/+1
| | | | | | | | (https://github.com/ruby/irb/pull/377) * Include updated help message https://github.com/ruby/irb/commit/ff129f3794
* [ruby/irb] Centralize coloring control (https://github.com/ruby/irb/pull/374)Stan Lo2022-06-281-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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
* [ruby/irb] [DOC] Fix formatting in docsPeter Zhu2022-06-201-3/+3
| | | | https://github.com/ruby/irb/commit/3ddc89e38c
* [ruby/irb] Fix documents for .irbrc pathKouhei Yanagita2022-05-181-3/+6
| | | | https://github.com/ruby/irb/commit/af99c01b0d
* [ruby/irb] Check colorize option correctly to clear char attr and don't use ↵aycabta2021-12-211-3/+6
| | | | | | it for tests https://github.com/ruby/irb/commit/de561cafeb
* [ruby/irb] Add resetting char attr that I forgotaycabta2021-12-211-1/+1
| | | | https://github.com/ruby/irb/commit/b5f953dc33
* [ruby/irb] Add information about --extra-doc-dir option in the commentsKaíque Kandy Koga2021-12-191-0/+1
| | | | https://github.com/ruby/irb/commit/ac3d4b9e79
* [ruby/irb] Update descriptions of methodsKaíque Kandy Koga2021-10-071-1/+1
| | | | | | | | | | | | 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
* [ruby/irb] Fix typo of variableaycabta2021-10-041-1/+1
| | | | https://github.com/ruby/irb/commit/692eb9b9b5
* [ruby/irb] Add doc about "echo on assignment"aycabta2021-09-271-0/+6
| | | | https://github.com/ruby/irb/commit/5af637b3c1
* [ruby/irb] Add a space before left parenaycabta2021-09-271-1/+1
| | | | https://github.com/ruby/irb/commit/973bac83ff
* [ruby/irb] Move IRB::TOPLEVEL_BINDING from exe/irb to lib/irb/workspace.rbaycabta2021-09-101-0/+2
| | | | https://github.com/ruby/irb/commit/e736a77076
* Add --autocomplete / --noautocomplete optionsaycabta2021-08-301-0/+3
|
* [ruby/irb] Pass local variables from workspace binding to lexerJeremy Evans2021-07-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [ruby/irb] Fix `Encoding::ConverterNotFoundError`Koichi ITO2021-05-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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. https://github.com/ruby/irb/blob/170531df19bce289444afe97360480efed5f27f0/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. https://github.com/ruby/irb/blob/170531df19bce289444afe97360480efed5f27f0/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
* [ruby/irb] Treat encodings in exception correctlyaycabta2021-05-111-4/+11
| | | | https://github.com/ruby/irb/commit/4452adbe04
* [ruby/irb] SIGINT should raise Interrupt after IRB sessionKoichi Sasada2021-04-021-1/+2
| | | | https://github.com/ruby/irb/commit/5832cfe75b
* [ruby/irb] Update help message for next context-mode of 4Jeremy Evans2021-02-271-5/+14
| | | | | | | 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
* [ruby/irb] use `RubyLex::TerminateLineInput` appropriately [Bug #17564]Nobuhiro IMAI2021-01-271-1/+1
| | | | | | | | * 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
* [ruby/irb] handle repeated exception separatelyNobuhiro IMAI2021-01-181-0/+2
| | | | https://github.com/ruby/irb/commit/fcf6b34bc5
* [ruby/irb] Fix comment, irb gem supports 2.5.0 or olderaycabta2021-01-081-1/+1
| | | | https://github.com/ruby/irb/commit/36118015ba
* [ruby/irb] Fix BACK_TRACE_LIMIT logicaycabta2021-01-081-2/+2
| | | | https://github.com/ruby/irb/commit/30dc5d43fe
* [ruby/irb] Use Exception#full_message to show backtrace in the correct orderaycabta2021-01-081-40/+34
| | | | | | [Bug #17466] https://github.com/ruby/irb/commit/1c76845cca
* [ruby/irb] fix typo in `IRB::Irb#convert_invalid_byte_sequence`Nobuhiro IMAI2021-01-081-1/+1
| | | | https://github.com/ruby/irb/commit/d09d3c3d68
* [ruby/irb] Escape invalid byte sequence in Exceptionaycabta2021-01-051-1/+25
| | | | | | This fixes ruby/irb#141. https://github.com/ruby/irb/commit/0815317d42
* [ruby/irb] Support arg for measure commandaycabta2020-12-221-2/+3
| | | | https://github.com/ruby/irb/commit/b43f35d8f3
* [ruby/irb] Add measure commandaycabta2020-12-201-1/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [ruby/irb] Stop using bang version for #inspect of resultaycabta2020-11-221-1/+1
| | | | https://github.com/ruby/irb/commit/fc1426d34e
* Fix small typo in comment in lib/irb.cAndrew Kerr2020-10-221-1/+1
|
* [ruby/irb] Drop OMIT_ON_ASSIGNMENT and add :truncate option for ↵aycabta2020-09-191-1/+1
| | | | | | ECHO_ON_ASSIGNMENT https://github.com/ruby/irb/commit/4c89b0775b
* [ruby/irb] Omit output if first line of multiline is too longaycabta2020-09-141-2/+12
| | | | https://github.com/ruby/irb/commit/0feeae38c5
* [ruby/irb] Add OMIT_ON_ASSIGNMENTaycabta2020-09-141-2/+24
| | | | | | | | | | | 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