lib/byebug/commands/display.rb in byebug-9.1.0 vs lib/byebug/commands/display.rb in byebug-10.0.0

- old
+ new

@@ -1,8 +1,10 @@ -require 'byebug/command' -require 'byebug/helpers/eval' +# frozen_string_literal: true +require "byebug/command" +require "byebug/helpers/eval" + module Byebug # # Custom expressions to be displayed every time the debugger stops. # class DisplayCommand < Command @@ -14,22 +16,22 @@ def self.regexp /^\s* disp(?:lay)? (?:\s+ (.+))? \s*$/x end def self.description - <<-EOD + <<-DESCRIPTION disp[lay][ <expression>] #{short_description} If <expression> specified, adds <expression> into display expression list. Otherwise, it lists all expressions. - EOD + DESCRIPTION end def self.short_description - 'Evaluates expressions every time the debugger stops' + "Evaluates expressions every time the debugger stops" end def execute return print_display_expressions unless @match && @match[1] @@ -38,27 +40,27 @@ end private def display_expression(exp) - print pr('display.result', n: Byebug.displays.size, + print pr("display.result", n: Byebug.displays.size, exp: exp, result: eval_expr(exp)) end def print_display_expressions - result = prc('display.result', Byebug.displays) do |item, index| + result = prc("display.result", Byebug.displays) do |item, index| active, exp = item { n: index + 1, exp: exp, result: eval_expr(exp) } if active end print result end def eval_expr(expression) error_eval(expression).inspect - rescue - '(undefined)' + rescue StandardError + "(undefined)" end end end