lib/byebug/states/regular_state.rb in byebug-4.0.5 vs lib/byebug/states/regular_state.rb in byebug-5.0.0

- old
+ new

@@ -1,12 +1,15 @@ require 'byebug/state' +require 'byebug/helpers/file' module Byebug # # Controls state of Byebug's REPL when in normal mode # class RegularState < State + include Helpers::FileHelper + attr_accessor :context, :frame, :display, :file, :line, :prev_line attr_writer :interface def initialize(context, display, file, interface, line) super(interface) @@ -34,11 +37,10 @@ # def proceed @proceed = true end - include FileFunctions # # Current (formatted) location # def location l = "#{normalize(file)} @ #{line}\n" @@ -85,15 +87,11 @@ args = context.frame_args(pos) return '' if args.empty? locals = context.frame_locals(pos) unless Setting[:callstyle] == 'short' my_args = args.map do |arg| - case arg[0] - when :block then prefix, default = '&', 'block' - when :rest then prefix, default = '*', 'args' - else prefix, default = '', nil - end + prefix, default = prefix_and_default_from(arg[0]) kls = if Setting[:callstyle] == 'short' || arg[1].nil? || locals.empty? '' else "##{locals[arg[1]].class}" @@ -171,8 +169,19 @@ def shortpath(fullpath) components = Pathname(fullpath).each_filename.to_a return fullpath if components.size <= 2 File.join('...', components[-3..-1]) + end + + def prefix_and_default_from(arg_type) + case arg_type + when :block + return ['&', 'block'] + when :rest + return ['*', 'args'] + else + return ['', nil] + end end end end