Skip to content

Extra vertical gap above the modeline when using tmux #663

Description

@mallet

Ghostel is amazing! But I found what seems to be an incorrect vertical alignment when running tmux.

In a raw Bash shell, there is no gap between the modeline and the prompt. See in the example below how the number 4 is truncated so that the prompt lands perfectly above the modeline. I think this is the proper behavior.
Image

But if I run a tmux instance, a gap appears between the tmux status bar and the modeline. See how the 6 is fully shown. The first line (6, here) is never truncated, because of the spurious gap between the tmux status bar and the modeline. I assume this is not expected, and that the proper behavior would be to remove the gap between the tmux status bar and the modeline, and show a truncated 5.
Image

The analysis of an AI is the following:

With these measurements:

(window-screen-lines) => 73.71428571428571

Ghostel normally rounds this down to 73 terminal rows. With a regular shell, ghostel--pixel-anchor can use the scrollback and applies a small vertical scroll, so the bottom is aligned correctly.

With tmux, Ghostel is on the alternate screen, which has no Ghostel scrollback above the visible terminal. ghostel--pixel-anchor then returns:

(1 . 0)

If Ghostel uses 74 rows (ceiling instead of floor), it returns:

(1 . 4)

and the display is aligned as expected: the first line is slightly truncated and the tmux status bar is flush with the modeline.

If that helps, here is a fix I applied in my Emacs configuration, where ceiling makes all the difference:

(defun my/ghostel-window-size (process windows)
  (let ((size (window-adjust-process-window-size-smallest process windows)))
    (if (and windows
             (buffer-live-p (process-buffer process))
             (with-current-buffer (process-buffer process)
               (derived-mode-p 'ghostel-mode)))
        (cons
         (car size)
         (max
          1
          (ceiling
           (apply
            #'min
            (mapcar
             (lambda (window)
               (with-selected-window window
                 (window-screen-lines)))
             windows)))))
      size)))

(setq-default window-adjust-process-window-size-function
              #'my/ghostel-window-size)

Thanks for the excellent work on this very useful extension!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions