fix: move stty size to first priority in backend-size

stty size via subprocess is the most reliable method — it
returns the correct 59x83 from the user's terminal. Move it
before ioctl to ensure it's tried first.
This commit is contained in:
2026-05-14 14:22:27 -04:00
parent fe301dc25b
commit 4b1ff3ed0f
2 changed files with 28 additions and 16 deletions

View File

@@ -22,7 +22,19 @@
(values))
(defmethod backend-size ((b simple-backend))
(or (ignore-errors
(or ;; stty size via subprocess — most reliable across all systems.
(ignore-errors
(let* ((out (uiop:run-program '("sh" "-c" "stty size < /dev/tty")
:output :string
:ignore-error-status t))
(parts (and out (uiop:split-string
(string-trim '(#\newline #\space) out)))))
(when (and parts (= (length parts) 2))
(let ((rows (parse-integer (first parts) :junk-allowed t))
(cols (parse-integer (second parts) :junk-allowed t)))
(when (and rows cols (> rows 0) (> cols 0))
(values cols rows))))))
(ignore-errors
(let* ((+tiocgwinsz+ 21523)
(winsize (sb-alien:make-alien sb-alien:unsigned-short 4)))
(unwind-protect