aboutsummaryrefslogtreecommitdiffstats
path: root/lib/irb.rb
Commit message (Collapse)AuthorAgeFilesLines
* [ruby/irb] Page evaluation result's outputStan Lo2023-11-301-3/+5
| | | | | | | | | | | | | | (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
* [ruby/irb] Rescue errors from main.to_s/inspect when formattingKasumi Hanazuki2023-11-281-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | prompt (https://github.com/ruby/irb/pull/791) Currently, IRB just terminates if `main.to_s` raises while IRB constructs the prompt string. This can easily happen if the user wants to start an IRB session in the instance scope of an uninitialized object, for example: ``` class C def initialize binding.irb @values = [] end def to_s = @values.join(',') # raises if uninitialized end C.new ``` This patch makes IRB rescue from such an exception and displays the class name of the exception instead of `main.to_s` to indicate some error has occurred. We may display more detailed information about the exception, but this patch chooses not to do so because 1) the prompt has limited space, 2) users can evaluate `to_s` in IRB to examine the error if they want, and 3) obtaining the details can also raise, which requires nested exception handling and can be complicated. https://github.com/ruby/irb/commit/412ab26067
* [ruby/irb] Fix exception(backtrace=nil) prints nothingtomoya ishida2023-11-251-35/+32
| | | | | | (https://github.com/ruby/irb/pull/782) https://github.com/ruby/irb/commit/fa9ecf9a5b
* [ruby/irb] Handle handle_exception's exceptiontomoya ishida2023-11-231-1/+8
| | | | | | (https://github.com/ruby/irb/pull/780) https://github.com/ruby/irb/commit/d42138c477
* [ruby/irb] Type based completion using Prism and RBStomoya ishida2023-11-081-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (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
* [ruby/irb] Minor refactors around irb.rbStan Lo2023-10-211-127/+79
| | | | | | | | | | | | | | | | (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
* [ruby/irb] Decouple RubyLex from prompt and line_notomoya ishida2023-10-121-40/+44
| | | | | | | | | | | | (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
* [ruby/irb] Clear all context usages in RubyLexStan Lo2023-10-041-7/+8
| | | | | | | | | | | | | | | | (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
* [ruby/irb] fixes https://github.com/ruby/irb/pull/524Chad Schroeder2023-08-291-1/+0
| | | | | | (https://github.com/ruby/irb/pull/696) https://github.com/ruby/irb/commit/59bcc07def
* [ruby/irb] irb:rdbg cleanups (https://github.com/ruby/irb/pull/697)Stan Lo2023-08-291-4/+3
| | | | | | | | * Remove unused method and constant from IRB::Debug * Update comments https://github.com/ruby/irb/commit/98914a963c
* [ruby/irb] Remove unused `PROMPT_N`Summer ☀️2023-08-291-9/+0
| | | | | | (https://github.com/ruby/irb/pull/685) https://github.com/ruby/irb/commit/66e69fa0dc
* [ruby/irb] Move input processing out of RubyLexStan Lo2023-08-211-20/+83
| | | | | | | | | | | | | | | | | | (https://github.com/ruby/irb/pull/683) * Add a test case for Ctrl-C handling * Test symbol aliases with integration tests There are a few places that also need to check symbol aliases before `Irb#eval_input`. But since the current command test skip them, we don't have test coverage on them. * Move each_top_level_statement and readmultiline to Irb This will save RubyLex from knowning information about commands and aliases. https://github.com/ruby/irb/commit/69cb5b5615
* [ruby/irb] Encapsulate input details in Statement objectsStan Lo2023-08-161-36/+6
| | | | | | | | | | (https://github.com/ruby/irb/pull/682) * Introduce Statement class * Split Statement class for better clarity https://github.com/ruby/irb/commit/65e8e68690
* [ruby/irb] Support seamless integration with ruby/debugStan Lo2023-08-131-7/+76
| | | | | | | | | | | | | | | | | | | | | | | | | | (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
* [ruby/irb] Move IO configuration to IRB::IrbStan Lo2023-08-131-1/+53
| | | | | | | | | (https://github.com/ruby/irb/pull/681) It shouldn't be `RubyLex`'s responsibility to handle IO. So this moves the configuration to `IRB::Irb`. https://github.com/ruby/irb/commit/daff750076
* [ruby/irb] Drop showing indent level number in DEFAULT prompt andtomoya ishida2023-08-121-9/+9
| | | | | | | | | | | INF_RUBY prompt (https://github.com/ruby/irb/pull/679) * Drop showing indent level number in DEFAULT prompt and INF_RUBY prompt * Update prompt part of test_rendering's expected result https://github.com/ruby/irb/commit/3847532e54
* [ruby/irb] Move assignment check to RubyLexStan Lo2023-08-111-45/+1
| | | | | | | | | | (https://github.com/ruby/irb/pull/670) Since assignment check relies on tokenization with `Ripper`, it feels like the responsibility of `RubyLex`. `Irb#eval_input` should simply get the result when calling `each_top_level_statement` on `RubyLex`. https://github.com/ruby/irb/commit/89d1adb3fd
* [ruby/irb] Don't echo an expression's result when it ends with aStan Lo2023-08-111-1/+2
| | | | | | | semicolon (https://github.com/ruby/irb/pull/669) https://github.com/ruby/irb/commit/50185c2833
* [ruby/irb] Fix nested IRB sessions' history savingStan Lo2023-08-091-0/+8
| | | | | | | | | | | | | | | | (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
* [ruby/irb] Refactor eval historyStan Lo2023-07-041-1/+1
| | | | | | | | | | | | (https://github.com/ruby/irb/pull/623) * Rename `ext/history.rb` to `ext/eval_history.rb` To confusion with `lib/irb/history.rb` * Add eval_history tests * Rename eval_history's History to EvalHistory to avoid confusion
* [ruby/irb] Reduce internal operations' exposure to benchmarkingStan Lo2023-06-301-18/+2
| | | | | | | | | | | | | | | | | | | | | (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`.
* [DOC] Fixes for link fragments (#7981)Burdette Lamar2023-06-281-1/+1
|
* [ruby/irb] Remove keyword exception from Context#evaluate becausetomoya ishida2023-06-271-15/+8
| | | | | | | the value is always nil (https://github.com/ruby/irb/pull/617) https://github.com/ruby/irb/commit/62691384f8
* [ruby/irb] Move input line mutation out of `Context#evaluate`Stan Lo2023-06-271-3/+20
| | | | | | | (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.
* [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