Skip to content

Commit

Permalink
Handle case when defined?(RubyVM.keep_script_lines) is false
Browse files Browse the repository at this point in the history
  • Loading branch information
kddnewton committed Aug 29, 2024
1 parent 79cdcfa commit e66fcf9
Showing 1 changed file with 13 additions and 9 deletions.
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

0 comments on commit e66fcf9

Please sign in to comment.