Skip to content

Commit 23cdc7c

Browse files
committed
Size PTY against the buffer window, not the selected one
`ghostel--start-process' recomputed the PTY rows/cols from `(window-body-height)' / `(window-max-chars-per-line)' with no window argument, i.e. against the *selected* window. `ghostel--init-buffer' had just sized the libghostty terminal against the *buffer's* window. When the two are different (popup display rules that don't select the popup, side windows, etc.) the PTY and the libghostty terminal start out disagreeing, and no SIGWINCH ever fires to reconcile them — alt-screen apps like Claude Code's /tui fullscreen lay out against the wrong size and the bottom rows look "visually collapsed" until the user resizes the frame (#192). Read the dims from `ghostel--term-rows' / `ghostel--term-cols' that `ghostel--init-buffer' (the only caller) just set, so the PTY and the libghostty terminal are guaranteed to match by construction.
1 parent 5321d1b commit 23cdc7c

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

lisp/ghostel.el

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2960,8 +2960,14 @@ matches the PTY window size, and stores the process in
29602960
"Start the shell process with a PTY.
29612961
When `default-directory' is a remote TRAMP path, spawn the shell
29622962
on the remote host."
2963-
(let* ((height (max 1 (window-body-height)))
2964-
(width (max 1 (window-max-chars-per-line)))
2963+
;; Read dims from the buffer-locals set by `ghostel--init-buffer'
2964+
;; (the only caller). Recomputing from `(window-body-height)' here
2965+
;; would query the *selected* window, which can differ from the
2966+
;; buffer's window when the buffer is shown in a popup that didn't
2967+
;; get selected — leaving the PTY and the libghostty terminal sized
2968+
;; against different windows (issue #192).
2969+
(let* ((height (max 1 ghostel--term-rows))
2970+
(width (max 1 ghostel--term-cols))
29652971
(remote-p (file-remote-p default-directory))
29662972
(shell (ghostel--get-shell))
29672973
(ghostel-dir (ghostel--resource-root))

test/ghostel-test.el

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6942,15 +6942,15 @@ internal `TERM=xterm-ghostty' so a `process-environment' lookup (which
69426942
returns the first match) resolves to the user's value."
69436943
(let ((captured-env nil)
69446944
(orig-make-process (symbol-function #'make-process)))
6945-
(cl-letf (((symbol-function #'window-body-height)
6946-
(lambda (&optional _w) 25))
6947-
((symbol-function #'window-max-chars-per-line)
6948-
(lambda (&optional _w) 80))
6949-
((symbol-function #'make-process)
6945+
(cl-letf (((symbol-function #'make-process)
69506946
(lambda (&rest plist)
69516947
(setq captured-env process-environment)
69526948
(apply orig-make-process plist))))
69536949
(with-temp-buffer
6950+
;; `ghostel--start-process' reads dims from these buffer-locals
6951+
;; (set by `ghostel--init-buffer' in the real flow).
6952+
(setq-local ghostel--term-rows 25
6953+
ghostel--term-cols 80)
69546954
(let* ((process-environment '("PATH=/usr/bin:/bin" "HOME=/tmp"))
69556955
(ghostel-shell "/bin/sh")
69566956
(ghostel-shell-integration nil)

0 commit comments

Comments
 (0)