Skip to content
Merged
Show file tree
Hide file tree
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
19 changes: 8 additions & 11 deletions openc3-cosmos-script-runner-api/app/models/running_script.rb
Original file line number Diff line number Diff line change
Expand Up @@ -730,22 +730,21 @@ def self.instrument_script(text, filename, mark_private = false)
instrumented_text = ''

@cancel_instrumentation = false
comments_removed_text = ruby_lex_utils.remove_comments(text)
num_lines = comments_removed_text.num_lines.to_f
num_lines = text.num_lines.to_f
num_lines = 1 if num_lines < 1
instrumented_text =
instrument_script_implementation(ruby_lex_utils,
comments_removed_text,
num_lines,
filename,
mark_private)
text,
num_lines,
filename,
mark_private)

raise OpenC3::StopScript if @cancel_instrumentation
instrumented_text
end

def self.instrument_script_implementation(ruby_lex_utils,
comments_removed_text,
text,
_num_lines,
filename,
mark_private = false)
Expand All @@ -755,14 +754,12 @@ def self.instrument_script_implementation(ruby_lex_utils,
instrumented_text = ''
end

ruby_lex_utils.each_lexed_segment(comments_removed_text) do |segment, instrumentable, inside_begin, line_no|
ruby_lex_utils.each_lexed_segment(text) do |segment, instrumentable, inside_begin, line_no|
return nil if @cancel_instrumentation
instrumented_line = ''
if instrumentable
# Add a newline if it's empty to ensure the instrumented code has
# the same number of lines as the original script. Note that the
# segment could have originally had comments but they were stripped in
# ruby_lex_utils.remove_comments
# the same number of lines as the original script
if segment.strip.empty?
instrumented_text << "\n"
next
Expand Down
Loading
Loading