# File lib/rbreadline.rb, line 8331
  def rl_display_match_list(matches, len, max)
    # How many items of MAX length can we fit in the screen window?
    max += 2
    limit = @_rl_screenwidth / max
    if (limit != 1 && (limit * max == @_rl_screenwidth))
      limit-=1
    end
    # Avoid a possible floating exception.  If max > _rl_screenwidth,
    #   limit will be 0 and a divide-by-zero fault will result.
    if (limit == 0)
      limit = 1
    end
    # How many iterations of the printing loop?
    count = (len + (limit - 1)) / limit

    # Watch out for special case.  If LEN is less than LIMIT, then
    #   just do the inner printing loop.
    #     0 < len <= limit  implies  count = 1.

    # Sort the items if they are not already sorted.
    if (!@rl_ignore_completion_duplicates)
      matches[1,len] = matches[1,len].sort
    end
    rl_crlf()

    lines = 0
    if (!@_rl_print_completions_horizontally)
      # Print the sorted items, up-and-down alphabetically, like ls.
      for i in 1 .. count
        l = i
        for j in 0 ... limit
          if (l > len || matches[l].nil?)
            break
          else
            temp = printable_part(matches[l])
            printed_len = print_filename(temp, matches[l])

            if (j + 1 < limit)
              @rl_outstream.write(' '*(max - printed_len))
            end
          end
          l += count
        end
        rl_crlf()
        lines+=1
        if (@_rl_page_completions && lines >= (@_rl_screenheight - 1) && i < count)
          lines = _rl_internal_pager(lines)
          return if (lines < 0)
        end
      end
    else
      # Print the sorted items, across alphabetically, like ls -x.
      i = 1
      while(matches[i])
        temp = printable_part(matches[i])
        printed_len = print_filename(temp, matches[i])
        # Have we reached the end of this line?
        if (matches[i+1])
          if ((limit > 1) && (i % limit) == 0)
            rl_crlf()
            lines+=1
            if (@_rl_page_completions && lines >= @_rl_screenheight - 1)
              lines = _rl_internal_pager(lines)
              return if (lines < 0)
            end
          else
            @rl_outstream.write(' '*(max - printed_len))
          end
        end
        i += 1
      end
      rl_crlf()
    end
  end