Can't change workspace after entering `debug`

未关闭
#952 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
ruby
领域
cli

调研方向

从 lib/irb/debug/ui.rb 大约第 59 行开始,然后重现报告中的操作顺序:在进入调试模式之前和之后更改工作区,或将工作区推入堆栈。验证进入调试模式后,工作区命令和语句仍继续使用所选工作区,包括更改工作区或将工作区推入堆栈之后。

由索引模型根据 Issue 内容生成。

描述

Description

After entering debug mode, all workspace functionality stops working. It's no longer possible to perform commands or statements under a different workspace after changing the workspace or pushing a workspace to the stack.

This happens because under debug mode, the current workspace is replaced and lines are always read with the context of the debug binding or the top level binding.

https://github.com/ruby/irb/blob/66318d0a343552715f214f07c57bc4a60552ccfd/lib/irb/debug/ui.rb#L59

Since it's not possible to exit debug mode, the workspace functionality is lost within irb for the remaining of the process.

irb(main):001> chws
Current workspace: main
=> nil
irb(main):002> chws foo
Current workspace: #<Foo:0x000000010a8ef250>
=> nil
irb(#<Foo:0x000000010a8ef250>):003> bar
=> "I'm a private method"
irb(#<Foo:0x000000010a8ef250>):004> chws
Current workspace: main
=> nil
irb(main):005> debug
irb:rdbg(main):006> chws foo
Current workspace: #<Foo:0x000000010a8ef250>
=> nil
irb:rdbg(#<Foo:0x000000010a8ef250>):007> bar
eval error: undefined local variable or method `bar' for main
  (rdbg)/test.rb:1:in `<main>'
nil
irb:rdbg(main):008> 

Result of irb_info

irb:rdbg(main):009> irb_info
Ruby version: 3.3.0
IRB version: irb 1.13.0 (2024-05-01)
InputMethod: RelineInputMethod with Reline 0.5.5
Completion: Autocomplete, RegexpCompletor
RUBY_PLATFORM: x86_64-darwin23
LANG env: en_CA.UTF-8
East Asian Ambiguous Width: 1

Terminal Emulator

kitty terminal

Setting Files

No settings file

主要语言
Ruby
星标
477
派生
165
平均合并
1 天 19 小时
30 天内合并 PR
5

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

ruby/irb 的其他 Issue

查看 ruby/irb 的全部 Issue

相似的 Issue

更多 Ruby Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。