summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-24 01:52:21 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-24 01:52:21 +0000
commit43e64b85852e72b1e7f28bdd0f33eaec57b906c8 (patch)
tree71c4e4046c0336ea1550e278b6b78279e0499d61 /lib
parent13247fa4173321798df994dbcf154c74519e448b (diff)
lib/irb.rb: simplified backtrace filtering
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61434 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/irb.rb29
1 files changed, 11 insertions, 18 deletions
diff --git a/lib/irb.rb b/lib/irb.rb
index 31190ba649..183ad813ee 100644
--- a/lib/irb.rb
+++ b/lib/irb.rb
@@ -508,31 +508,24 @@ module IRB
lasts = []
levels = 0
if exc.backtrace
- filtered_line_count = 0
- exc.backtrace.each_with_index do |m, i|
- num_str = (i + 1 - filtered_line_count).to_s.rjust(9, ' ')
- m = @context.workspace.filter_backtrace(m) unless irb_bug
- if m
- if messages.size < @context.back_trace_limit
- messages.push "#{num_str}: from "+m
- else
- lasts.push "#{num_str}: from "+m
- if lasts.size > @context.back_trace_limit
- lasts.shift
- levels += 1
- end
- end
- else
- filtered_line_count += 1
+ count = 0
+ exc.backtrace.each do |m|
+ m = @context.workspace.filter_backtrace(m) or next unless irb_bug
+ m = sprintf("%9d: from %s", (count += 1), m)
+ if messages.size < @context.back_trace_limit
+ messages.push(m)
+ elsif lasts.size < @context.back_trace_limit
+ lasts.push(m).shift
+ levels += 1
end
end
end
print "Traceback (most recent call last):\n"
unless lasts.empty?
- print lasts.reverse.join("\n"), "\n"
+ puts lasts.reverse
printf "... %d levels...\n", levels if levels > 0
end
- print messages.reverse.join("\n"), "\n"
+ puts messages.reverse
print exc.class, ": ", exc, "\n"
print "Maybe IRB bug!\n" if irb_bug
end