Repository navigation
Keep line-mode point and markers put across a resize - #702
Merged
Merged
Conversation
Two independent defects moved point out of the input region in line mode, both visible after resizing a window over a long scrollback. The line-count branch of `ghostel--anchor-window' walked back from `point-max' by the full screen-line count. That fits only when `point-max' begins a trailing empty row, which line mode removes when it trims the renderer's blank tail, so the last row landed one line below the window and redisplay answered a forced `window-start' by relocating point to the middle of the window. The branch runs on terminal frames and wherever the pixel measurement is unavailable. The renderer pinned saved markers from inside `commitResize', after a FULL redraw had already erased the buffer. `bufferPosToPin' derives a screen row from the buffer, so every window point, window start and mark mapped to row 0 and came back as buffer position 1. Line mode sets FULL on every redraw, so any resize hit it. Skipping the pin on an erased buffer restores the raw offsets, which drift only when a row rewraps. Closes #699
dakra
force-pushed
the
fix/699-line-mode-resize-point
branch
from
September 18, 2026 09:15
0cf5efc to
67f43b3
Compare
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #699.
In line mode, after
seq 1000, the first window resize threw point intothe scrollback and the next one threw it to the top of the buffer. Two
independent defects, both reproduced and measured in live sessions.
Point relocated to the middle of the window
The line-count branch of
ghostel--anchor-windowwalked back frompoint-maxby the full screen-line count. That is correct only whenpoint-maxbegins a trailing empty row, which is what the renderernormally leaves. Line mode trims that tail, so
point-maxends at theend of the prompt row, the walk-back lands one line too high, and the
prompt row falls below the window bottom.
set-window-startsetsforce_start, and redisplay answers an invisible point by moving it tothe middle of the window rather than scrolling.
Measured in a 22-row window with the prompt on buffer line 1002:
Graphical frames use the exact pixel anchor and were unaffected. The
fallback runs on terminal frames, on Emacs 28, and whenever the pixel
measurement is unavailable.
Point, window start and mark collapsing to position 1
The renderer pins saved markers from inside
commitResize, but a FULLredraw erases the buffer before that.
bufferPosToPinderives a screenrow with
line-number-at-pos, so against an empty buffer every savedposition maps to row 0 and is restored as buffer position 1. Line mode
passes FULL on every redraw, so any resize hit it. Graphical frames were
affected too.
With the mark parked in the scrollback and a width resize applied:
Point usually survived because
ghostel--line-mode-restoreputs it backfrom its input-region offset. Once point is outside that region, which
is exactly where the first defect left it, nothing restores it.
Known ceiling
Skipping the pin restores raw buffer offsets, so a marker on a row that
rewraps during a width resize drifts by the rewrap delta instead of
following its row. Pinning accurately would mean moving the full-redraw
clear below the pin, which starts running scrollback eviction on a path
where it currently never executes. Eviction ordering here has produced
two silent desyncs before, so that trade is not worth an occasional
few-character drift. The reported collapse to the buffer start is gone.
Tests
Two native regression tests, both confirmed to fail with the fixes
reverted and the module and byte-code rebuilt:
mode produces and the one case the existing position-preservation
family did not cover
make -j8 allpasses from cleared test stamps. Both symptoms were alsore-checked live, on terminal and graphical frames.