class Byebug::ListCommand

def set_line_range(listsize, maxline)

Parameters:
  • maxline () -- - max line number that can be printed
  • listsize () -- - number of lines to be printed
def set_line_range(listsize, maxline)
  if !@match || !(@match[1] || @match[2])
    b = @state.previous_line ?
    @state.previous_line + listsize : @state.line - (listsize/2)
  elsif @match[1] == '-'
    b = if @state.previous_line
          if  @state.previous_line > 0
            @state.previous_line - listsize
          else
            @state.previous_line
          end
        else
          @state.line - (listsize/2)
        end
  elsif @match[1] == '='
    @state.previous_line = nil
    b = @state.line - (listsize/2)
  else
    b, e = @match[2].split(/[-,]/)
    if e
      b = b.to_i
      e = e.to_i
    else
      b = b.to_i - (listsize/2)
    end
  end
  if b > maxline
    errmsg "Invalid line range"
    return [ -1, -1 ]
  end
  b = [1, b].max
  e ||=  b + listsize - 1
  if e > maxline
    e = maxline
    b = e - listsize + 1
    b = [1, b].max
  end
  return [ b, e ]
end