                                            .ratio)))))
       (while (or first-run
                  (and .repeat
-                      .size
-                      (or .size)
-                      (>= (window-text-height) (1+ requested-size))))
+                      (jail-windows--space-available-check
+                       (window-text-height)
+                       (max jail-windows-repeat-minimum-vert
+                            jail-windows--real-repeat-minimum-vert)
+                       .size
+                       .ratio)))
         (setq first-run nil
               old-window (selected-window))
         (jail-windows--add-to-groups old-window .groups)


;;; Layout Activation

(defun jail-windows--add-to-groups (window groups)
  "[Internal]"
  (when groups


;;; Core functionality

(defun jail-windows--group-buffer-compare-fn (buffer buffer-matches-p)
  "[Internal] Function to test buffer against group definition. This will be
used as `-compare-fn' in package `dash'."
  (let ((ret nil))
    (when (eq t buffer-matches-p)
      (setq ret t))
    (when (and (not ret)
               (stringp buffer-matches-p))
      (setq ret (string-match-p buffer-matches-p (buffer-name buffer))))
    (when (and (not ret)
               (functionp buffer-matches-p))
      (setq ret (funcall buffer-matches-p buffer)))
    ret))

(defun jail-windows--find-window-for-buffer (frame buffer alist)
  "[Internal]"
  (let ((available-windows (window-list frame 'nominibuf))
        (matched-group))
    ;; For each group defined in the jail-windows' window-options
    (--each-while (jail-windows--get-option frame 'groups)
        ;; Stop iterating when a group has matched
        (not matched-group)
      ;; Pull the group definition and the window list from the group list
      (let ((group-defs (car it))
            (window-list (-remove (-not #'window-live-p) (cdr it)))
            (-compare-fn #'jail-windows--group-buffer-compare-fn))
        ;; Check if this group has live windows and matches against the buffer
        (if (and window-list
                 (-contains? group-defs buffer))
            ;; When it does match, only use windows from this group
            (progn
              (setq matched-group t)
