summaryrefslogtreecommitdiff
path: root/lib/irb
AgeCommit message (Collapse)Author
2023-01-14[ruby/irb] Store context in RubyLexStan Lo
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-12[ruby/irb] Avoid calling private methods on the main objectStan Lo
(https://github.com/ruby/irb/pull/498) When the main object is frozen, `IRB` wraps a `SimpleDelegator` around it. But because `SimpleDelegator` doesn't delegate private methods, methods like `require_relative` or `const_get` would cause error, which are needed for lazily loading commands. This commit works around this limitation by avoiding those private method calls when setting up command execution.
2023-01-12[ruby/irb] Remove redundant argument defaults from some RubyLexStan Lo
methods (https://github.com/ruby/irb/pull/502) * Remove unnecessary parameter defaults These methods are always called with tokens specified. So their default `@tokens` value is never used and is misleading. * Remove unnecessary context default * Require tokens for `RubyLex#check_state`
2023-01-11[ruby/irb] Formatting to header stylesHiroshi SHIBATA
https://github.com/ruby/irb/commit/cef125850d
2023-01-11[ruby/irb] After Ruby 2.0, coding is always utf-8Hiroshi SHIBATA
https://github.com/ruby/irb/commit/7a94bc4135
2023-01-11[ruby/irb] Removed Release Version and Revisions for old VCS softwareHiroshi SHIBATA
https://github.com/ruby/irb/commit/07fae94862
2023-01-11[ruby/irb] Drop unused arguments in `RubyLex`Stan Lo
(https://github.com/ruby/irb/pull/504) * Simplify `RubyLex#set_prompt` It's optional argument is never used by any caller. * Remove the optional `p` argument from `RubyLex#set_input` The argument is only used in a test case, which can be easily replaced by a block argument.
2023-01-04[ruby/irb] workspace.rb cleanupStan Lo
(https://github.com/ruby/irb/pull/489) * Remove unnecessary Binding#source_location check `Binding#source_location` was added in 2.6, which is the minimum supported version now. So this check is no longer necessary. * Remove unused IRB.delete_caller This method was added in the earliest version of IRB: https://github.com/ruby/irb/commit/f47808999d24865fba1929dea1a7011ff5a517d6 But it's not currently referenced by anything. We can verify this with a org-wide search result: https://github.com/search?q=org%3Aruby+delete_caller&type=code
2023-01-02[ruby/irb] Fix prompt and code mismatchtomoya ishida
(https://github.com/ruby/irb/pull/386) * fix prompt and code mismatch * Add test for prompt and code mismatch bug https://github.com/ruby/irb/commit/a5765d8177 Co-authored-by: Stan Lo <stan001212@gmail.com>
2022-12-27[ruby/irb] Refactor RubyLex#process_literal_typeMau Magnaguagno
(https://github.com/ruby/irb/pull/350) Simplify part of regex ``[_a-zA-Z0-9]`` with equivalent shorthand ``\w``. Replace case-when with match ``$1`` or default value ``?"``, making intention more clear.
2022-12-27[ruby/irb] Fix wrong conf path with XDG_CONFIG_HOME. It should be under the ↵Hiroshi SHIBATA
HOME directory, not current directory https://github.com/ruby/irb/commit/33a5e55ffd
2022-12-26[ruby/irb] fix indent depth calculation after heredoc and embdoctompng
https://github.com/ruby/irb/commit/b7973dd2d2
2022-12-26[ruby/irb] fix auto-indent after multiline stringtompng
https://github.com/ruby/irb/commit/f65ec49684
2022-12-20[ruby/irb] Version 1.6.2Takashi Kokubun
https://github.com/ruby/irb/commit/a8ea9963c6
2022-12-20[ruby/irb] Respect DLEXT to force-load debug.soTakashi Kokubun
(https://github.com/ruby/irb/pull/481) Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org> Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2022-12-13[ruby/irb] Version 1.6.1Takashi Kokubun
https://github.com/ruby/irb/commit/229476ba76
2022-12-12[ruby/irb] `show_doc` command should take non-string argument tooStan Lo
(https://github.com/ruby/irb/pull/478) Given that `show_doc` already supports syntax like `String#gsub`, it should be able to take it in non-string form too, like `edit` and `show_source` do. This ensures users can have a consistent syntax on argument between different commands.
2022-12-09[ruby/irb] Fix step command (https://github.com/ruby/irb/pull/477)Stan Lo
The current `next` pre-command workaround on IRB source stepping moves the location by 1 extra line. A better way is to make `debug` skip IRB frames completely, which is what this commit does. It also fixes the step command's test. The `|` in regexp was not escaped so it was always incorrectly matched.
2022-12-09[ruby/irb] Version 1.6.0Takashi Kokubun
https://github.com/ruby/irb/commit/d799c5c9da
2022-12-08[ruby/irb] Add show_doc as an alias to the help commandStan Lo
(https://github.com/ruby/irb/pull/475) In the long-term, we want to align with `Pry`, `byebug` and `debug` to use the `help` command to list all commands, which is what `show_cmds` currently does. And `show_doc` will be the command to look up Ruby APIs. By aliasing `show_doc` to the current `help` now, users will have time to get use to it.
2022-12-08[ruby/irb] Gracefully handle missing command argumentStan Lo
(https://github.com/ruby/irb/pull/473) * Handle file loading commands' argument error gracefully Currently, if users don't provide an argument to `source`, `irb_load`, and `irb_require`, IRB raises `ArgumentError` with full stacktrace. This is confusing because it looks similar to when IRB has internal issues. The message also isn't helpful on helping users avoid the error. So in this commit, I add a new `CommandArgumentError` for commands to raise explicitly when users' input doesn't satisfy a command's argument requirement. * Gracefully handle `fg` command's argument requirement
2022-12-08[ruby/irb] Add "show_cmds" command to list all commands'Stan Lo
descriptions (https://github.com/ruby/irb/pull/463) https://github.com/ruby/irb/commit/7e857655ac
2022-12-07[ruby/irb] Lazily load the multi-irb extensionStan Lo
(https://github.com/ruby/irb/pull/472) * Lazily load the multi-irb extension We now have plan to implement a command that prints all commands' information, which will need to load all command files without actually running them. But because the `multi-irb` extension patches IRB's top-level methods, loading it would cause unintentional side-effects. So this commit moves related requires into command execution to avoid the problem. * Make extend_irb_context private Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
2022-12-06[ruby/irb] Allow disabling autocompletion withStan Lo
`IRB_USE_AUTOCOMPLETE=false` (https://github.com/ruby/irb/pull/469) * Allow using IRB_USE_AUTOCOMPLETE=false to disable autocompletion Currently, the only 2 ways to disable autocompletion are: 1. Create `.irbrc` and set `IRB.conf[:USE_AUTOCOMPLETE] = false` 2. Add the `--noautocomplete` flag when using the `irb` executable Both of them are less convenient than setting a env var and are lesser known to devs. And given the number of problems the autocompletion has (see #445), I think we should allow disabling it with a simple `IRB_USE_AUTOCOMPLETE=false`. * Mention some env var configs in the README
2022-11-30[ruby/irb] Use class methods of `File` over `Kernel.open`Nobuyoshi Nakada
https://github.com/ruby/irb/commit/e0ec5e1bd8
2022-11-30[ruby/irb] Make sure ls doesn't return an arrayTakashi Kokubun
(https://github.com/ruby/irb/pull/461) https://github.com/ruby/irb/commit/367797bb05
2022-11-28[ruby/irb] Version 1.5.1Takashi Kokubun
https://github.com/ruby/irb/commit/f9507923fa
2022-11-28[ruby/irb] Fix the debug.gem force-loader for Ruby 3.2Takashi Kokubun
(https://github.com/ruby/irb/pull/458) * Fix the debug.gem force-loader for Ruby 3.2 * Support 1.7.0dev format as well
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-20[ruby/irb] Version 1.5.0Takashi Kokubun
Asked by ko1 to release https://github.com/ruby/irb/pull/444 for simplifying https://github.com/ruby/debug/pull/808, and hsbt made me a gem owner for this. Stan said 1.4.3 should have been 1.5.0, but now that it's already released and it's not worth yanking it, we're not doing that change. However, now that this release includes `debug` and `edit`, I think it's a good opportunity to hit the version 1.5.0. https://github.com/ruby/irb/commit/85937d71f6
2022-11-20[ruby/irb] Add edit command (https://github.com/ruby/irb/pull/453)Stan Lo
* Add edit command * Make find_source a public singleton method * Add document for the edit command * Make find_end private * Remove duplicated private https://github.com/ruby/irb/commit/4321674aa7 Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
2022-11-19[ruby/irb] Document a full list of commandsTakashi Kokubun
(https://github.com/ruby/irb/pull/451) * Document a full list of commands * Document debug as well * Make it less duplicated
2022-11-18[ruby/irb] Discover and load debug.gem even if it's not in GemfileTakashi Kokubun
(https://github.com/ruby/irb/pull/448) * Minor fixes on debug command * Discover and load debug.gem even if it's not in Gemfile * Eliminate else for rescue * Discover the latest one from all gem paths
2022-11-18[ruby/irb] Minor fixes on debug commandTakashi Kokubun
(https://github.com/ruby/irb/pull/447) * Minor fixes on debug command * Update lib/irb/cmd/debug.rb
2022-11-18[ruby/irb] Add debug command (https://github.com/ruby/irb/pull/446)Stan Lo
https://github.com/ruby/irb/commit/30faa13fa3
2022-11-17[ruby/irb] Bump up 1.4.3Hiroshi SHIBATA
https://github.com/ruby/irb/commit/1bddbbf602
2022-11-17Drop Ruby 2.5 supportst0012
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[ruby/irb] Fix https://github.com/ruby/irb/pull/295: Ignore JavaPatrick Plenefisch
package reference objects in JRuby https://github.com/ruby/irb/commit/84d030182d
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-15[ruby/irb] Deprecate reidline flagsst0012
https://github.com/ruby/irb/commit/9957e83f7d
2022-11-15[ruby/irb] Rename leftover Reidline referencesst0012
https://github.com/ruby/irb/commit/0ed8b103ed
2022-11-10[ruby/irb] Transform ls's --grep/-G option to keyword argsTakashi Kokubun
(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[ruby/irb] Make $ and @ default aliasesTakashi Kokubun
(https://github.com/ruby/irb/pull/438) https://github.com/ruby/irb/commit/0613589476
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-07[ruby/irb] Don't lazily retrieve gem specs for completionStan Lo
There are a few downsides of the current approach: 1. Because gem specs are lazily retrieved, this computation happens in every irb completion test case, which is not necessary. (In tests we don't cache the result of `retrieve_files_to_require_from_load_path`) 2. Gem::Specification.latest_specs is sensible to the content of LOAD_PATH. And when combined with 1, tests fail "randomly" if they try to mutate LOAD_PATH, even though the test subject it's something else. So by pre-computing and storing the gem paths in a constant, it guarantees that the computation only happens once and it doesn't get affected by test cases. One argument could be made against the change is that, it'll store unnecessary data for users that disable autocompletion. But the counter-arguments are: 1. Since autocompletion is enabled by default, this should not be the case for most users. 2. For users with autocompletion enabled, IRB already caches the result of `retrieve_files_to_require_from_load_path` in memory, which should have a similar size of GEM_SPECS. And we currently haven't received any report about problems caused by such memory consumption. https://github.com/ruby/irb/commit/c671d39020
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-11-03[ruby/irb] Refactor RubyLex and its testsStan Lo
(https://github.com/ruby/irb/pull/427) * Make sure `RubyLex#set_input`'s context is always present in tests In real-world scenarios, the context should always be non-nil: https://github.com/ruby/irb/blob/master/lib/irb.rb#L489 So we should make sure our test setup reflects that. * Make context a required keyword Since in practice, `set_input`'s context should always be non-nil, its parameters should reflect that. And since `RubyLex#check_state` is only called by `#lex` and `#set_input`, both of which now always require context, we can assume its context should be non-nil too. https://github.com/ruby/irb/commit/1aeeb86203
2022-10-28[ruby/irb] Do not make non-existent XDG directory on startNobuyoshi Nakada
(https://github.com/ruby/irb/pull/357) https://github.com/ruby/irb/commit/298b134792
2022-10-28[ruby/irb] Update regarding NO_COLOR valueNobuyoshi Nakada
https://no-color.org has been updated (jcs/no_color#83): > Command-line software which adds ANSI color to its output by default should check for a `NO_COLOR` environment variable that, when present and **not an empty string** (regardless of its value), prevents the addition of ANSI color. https://github.com/ruby/irb/commit/46e0f7e370 Co-authored-by: Stan Lo <stan001212@gmail.com>
2022-10-24[ruby/irb] Move require out of repeated execution pathst0012
SHOW_DOC_DIALOG will be called repeatedly whenever the corresponding key is pressed, but we only need to require rdoc once. So ideally the require can be put outside of the proc. And because when rdoc is not available the entire proc will be nonfunctional, we can stop registering the SHOW_DOC_DIALOG if we failed to require rdoc. https://github.com/ruby/irb/commit/b1278b7320