Skip to content

scroll-on-input doesn't reset view when scrolled via pixel-scroll-precision-mode` #113

Description

@emil-e

When pixel-scroll-precision-mode is enabled and the user scrolls up into scrollback, typing doesn't snap the view back to the prompt — the input is sent but the window stays showing scrollback.

Root cause: pixel-scroll-precision scrolls by changing Emacs's window-start and moves point upward to keep it visible. When the user types, ghostel--self-insert calls ghostel--scroll-bottom to reset the terminal's internal viewport, but point remains in the scrollback region.

The delayed redraw then sees point < viewport-start (line 2284), preserves point via saved-marker, and skips the set-window-start anchor (line 2316: (when (and vs (>= pt vs)) ...)) — intentionally, to avoid yanking scrollback readers back to the bottom. But in the scroll-on-input case, the user is done reading scrollback.

For comparison, vterm doesn't have this issue because its C module (vterm--update) controls both the terminal state and Emacs point in one call — there's no split between terminal viewport and Emacs window position.

Suggested fix: In ghostel--self-insert and ghostel--send-event, move point to the bottom after resetting the terminal viewport:

(when (and ghostel-scroll-on-input ghostel--term)
  (ghostel--scroll-bottom ghostel--term)
  (goto-char (point-max))          ; ← add this
  (setq ghostel--force-next-redraw t))

This ensures the delayed redraw sees point in the viewport and anchors window-start correctly. The existing saved-marker logic for copy-mode and passive scrollback reading is unaffected.

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