diff --git a/winum.el b/winum.el index d4da7f8..257af3e 100644 --- a/winum.el +++ b/winum.el @@ -314,8 +314,9 @@ PREFIX must be a key sequence, like the ones returned by `kbd'." ;;;###autoload (defun winum-get-window-by-number (n) "Return window numbered N if exists, nil otherwise." - (when (and (>= n 0) (< n (1+ winum--window-count))) - (aref (winum--get-window-vector) n))) + (let ((window-vector (winum--get-window-vector))) + (when (and (>= n 0) (< n (length window-vector))) + (aref window-vector n)))) ;;;###autoload (defun winum-get-number-string (&optional window)