Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle case when defined?(RubyVM.keep_script_lines) is false #1115

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions lib/debug/source_repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ def get iseq
end
end

def orig_src iseq
lines = iseq_src iseq
line = iseq.first_line
if line > 1
[*([''] * (line - 1)), *lines]
else
lines
end
end

if defined?(RubyVM.keep_script_lines)
# Ruby 3.1 and later
RubyVM.keep_script_lines = true
Expand All @@ -45,14 +55,8 @@ def add iseq, src
end
end

def orig_src iseq
lines = iseq.script_lines&.map(&:chomp)
line = iseq.first_line
if line > 1
[*([''] * (line - 1)), *lines]
else
lines
end
private def iseq_src iseq
iseq.script_lines&.map(&:chomp)
end

def get_colored iseq
Expand Down Expand Up @@ -132,7 +136,7 @@ def add iseq, src
end
end

def orig_src iseq
private def iseq_src iseq
if si = get_si(iseq)
si.src
end
Expand Down
Loading