summaryrefslogtreecommitdiff
path: root/lib/irb/context.rb
AgeCommit message (Collapse)Author
2023-12-12[ruby/irb] [DOC] RDoc for module IRBBurdette Lamar
(https://github.com/ruby/irb/pull/738) [DOC] RDoc for module IRB https://github.com/ruby/irb/commit/f3a0626298
2023-11-29[ruby/irb] Use gem repl_type_completor, remove type_completiontomoya ishida
implementation (https://github.com/ruby/irb/pull/772) https://github.com/ruby/irb/commit/a4868a5373
2023-11-26[ruby/irb] Display aliases in help messageStan Lo
(https://github.com/ruby/irb/pull/788) Similar to Pry, it displays user-defined aliases in the help message with a dedicated section. With the current default aliases, it looks like: ``` ...other sections... Aliases $ Alias for `show_source` @ Alias for `whereami` ``` https://github.com/ruby/irb/commit/2a0eacc891
2023-11-22[ruby/irb] Require prism >= 0.18.0 (MatchWriteNode#targets andtomoya ishida
CaseMatchNode) (https://github.com/ruby/irb/pull/778) https://github.com/ruby/irb/commit/943c14b12e
2023-11-08[ruby/irb] Type based completion using Prism and RBStomoya ishida
(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
2023-08-29[ruby/irb] Print deprecation message for prompt_n methodsStan Lo
(https://github.com/ruby/irb/pull/691) They were removed in #685, but we should still keep them to avoid breaking changes to tools like Chef. https://github.com/chef/chef/blob/533ff089479763f29045e4e6ddf388b73fc99338/lib/chef/shell.rb#L138 https://github.com/ruby/irb/commit/b585e0c835
2023-08-29[ruby/irb] Remove unused `PROMPT_N`Summer ☀️
(https://github.com/ruby/irb/pull/685) https://github.com/ruby/irb/commit/66e69fa0dc
2023-08-13[ruby/irb] Support seamless integration with ruby/debugStan Lo
(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-09[ruby/irb] Fix nested IRB sessions' history savingStan Lo
(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-07-14[ruby/irb] Fix history-saving featureStan Lo
(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. - https://github.com/ruby/irb/blob/3ac96be660bf052902fb4e532c7a46cf294b71eb/lib/irb/history.rb#L10 - https://github.com/ruby/irb/blob/3ac96be660bf052902fb4e532c7a46cf294b71eb/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-03[ruby/irb] Stop treating history-saving logic as extensionStan Lo
(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-06-30[ruby/irb] Reduce internal operations' exposure to benchmarkingStan Lo
(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-27[ruby/irb] Remove keyword exception from Context#evaluate becausetomoya ishida
the value is always nil (https://github.com/ruby/irb/pull/617) https://github.com/ruby/irb/commit/62691384f8
2023-06-27[ruby/irb] Move input line mutation out of `Context#evaluate`Stan Lo
(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-02-18[ruby/irb] Remove unused context argument from Worksapce#evaluateStan Lo
(https://github.com/ruby/irb/pull/488) The context argument was introduced in this change: https://github.com/ruby/irb/commit/6806669d178f90f38b99c144bdfee06bdb93a229#diff-296327851fb7a2c307c2d0693b769f58c01aaf315972f290500d10081ee200a9 perhaps for potential usages. But after that it's never used.
2023-01-11[ruby/irb] Formatting to header stylesHiroshi SHIBATA
https://github.com/ruby/irb/commit/cef125850d
2023-01-11[ruby/irb] Removed Release Version and Revisions for old VCS softwareHiroshi SHIBATA
https://github.com/ruby/irb/commit/07fae94862
2022-11-21[ruby/irb] Add commands to start and use the debuggerTakashi Kokubun
(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-15[ruby/irb] Deprecate USE_RELINE and USE_REIDLINEst0012
Based on this commit: https://github.com/ruby/irb/commit/93f87ec65344b44123b0150a5fc07de1fd4c80c4 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-07[ruby/irb] Support non-string input in show_sourceTakashi Kokubun
(https://github.com/ruby/irb/pull/430) * Support non-string input in show_source * Test show_source as a method
2022-11-03[ruby/irb] Allow non-identifier aliases like Pry's @ and $Takashi Kokubun
(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-10-18[ruby/irb] Always use local variables in current context to parse code ↵tomoya ishida
(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 <[email protected]> * Add a comment why assignment expression check should be done before evaluate https://github.com/ruby/irb/commit/c8b3877281 Co-authored-by: Stan Lo <[email protected]> Co-authored-by: Takashi Kokubun <[email protected]>
2022-10-05[ruby/irb] Use USE_REIDLINE for backword compatibilityHiroshi SHIBATA
https://github.com/ruby/irb/commit/e58a3c1b39
2022-10-05[ruby/irb] Rename IDB::ReidlineInputMethod to IRB::RelineInputMethodGannon McGibbon
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-03[ruby/irb] Remove unnecessary Thread presence checkst0012
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-09-17[ruby/irb] Support --noscript option to not use first non-option argument as ↵Jeremy Evans
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-06-28[ruby/irb] Centralize coloring control (https://github.com/ruby/irb/pull/374)Stan Lo
* 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
2021-10-11[ruby/irb] Add --extra-doc-dir option to show doc dialogaycabta
https://github.com/ruby/irb/commit/3f79cb506f
2021-10-11[ruby/irb] Add periods to docaycabta
https://github.com/ruby/irb/commit/6330601629
2021-10-11[ruby/irb] Set default return_formataycabta
https://github.com/ruby/irb/commit/7ee15bc668
2021-10-07[ruby/irb] Make IRB::Context#exit call super if UncaughtThrowErrorJeremy Evans
Fixes calling exit after binding.irb. Fixes [Bug #18234] https://github.com/ruby/irb/commit/4ea8d376f2
2021-09-27[ruby/irb] Add doc about "echo on assignment"aycabta
https://github.com/ruby/irb/commit/5af637b3c1
2021-09-27[ruby/irb] Add blank lines to sample code in doc for readabilityaycabta
https://github.com/ruby/irb/commit/123b7e53ee
2021-09-27[ruby/irb] Fix sample code in docaycabta
https://github.com/ruby/irb/commit/642adbe968
2021-08-30Add --autocomplete / --noautocomplete optionsaycabta
2020-09-19[ruby/irb] Drop OMIT_ON_ASSIGNMENT and add :truncate option for ↵aycabta
ECHO_ON_ASSIGNMENT https://github.com/ruby/irb/commit/4c89b0775b
2020-09-14[ruby/irb] Add OMIT_ON_ASSIGNMENTaycabta
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-04-07[DOC] get rid of parsing as TIDYLINK unintentionallyNobuyoshi Nakada
2020-01-21[ruby/irb] Add newline_before_multiline_outputKenta Murata
https://github.com/ruby/irb/commit/9eb1801a66
2019-12-24[ruby/irb] Remove warning message to bundle on Ruby 2.7.0aycabta
https://github.com/ruby/irb/commit/d9a7844f50
2019-11-26Slightly fix the warning message [ci skip]Takashi Kokubun
I'm not sure, but maybe it was gramatically incorrect?
2019-11-26Suggest an alternative to suppress the irb warningTakashi Kokubun
2019-11-21Add a warning message and --legacy of an alias of --singlelineaycabta
2019-11-21Use singleline/multiline instead of readline/reidlineaycabta
2019-10-24Remove unsused output_method argumentJeremy Evans
Fixes Ruby Bug 9876.
2019-08-16Don't echo results of assignment expressionsSteven Willis
2019-08-06Revert "Don't echo results of assignment expressions"aycabta
This reverts commit 1ee88c51b3c319b74b69540e111e4a1c24833cad.
2019-08-06Don't echo results of assignment expressionsSteven Willis
2019-07-15Auto indent in IRB is enabled by defaultaycabta
2019-05-27context.rb: hide wrapping linesNobuyoshi Nakada
* 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.