Preserve point and window-start across streaming rerenders#566
Conversation
|
Thank you for the PR. I've tried the patch briefly and ran into issues with point placed in unexpected places in viewport buffer when multiple permission dialogs came through. It could be unrelated. Will have to have another play with it later on. ps. IIRC, the previous implementation remembered region too? |
Each streaming chunk delete-and-reinserts the in-progress block, which displaces any markers inside that region to its start. `(point-marker)` in the viewport branch and `save-mark-and-excursion`/`save-excursion` (in `agent-shell-ui-update-fragment` and `shell-maker-with-auto-scroll-edit`) all rely on markers, so cursor and viewport jumped to the block header when reading mid-stream. Switch to integer-based save/restore for point and window-start: inside `agent-shell-ui-update-fragment` (covers the viewport flow) and around `shell-maker-with-auto-scroll-edit` in the main shell branch (overrides shell-maker's broken `save-excursion`).
2f9490e to
7832e7d
Compare
|
Thanks for trying it out. Good point on region. I’d missed that One caveat: for a region inside the block being delete/reinserted, this is still positional rather than semantic. It restores the same offsets after rerender, not necessarily the same logical text if the replacement changes substantially. But it avoids the marker displacement to the block start, which was the original issue. On the viewport permission-dialog issue: I couldn’t spot a direct cause in this patch. Permission dialogs still explicitly jump to the latest permission button after rendering, including in the viewport buffer. Happy to look more if you find a reproducible case. |
Hello Alvaro,
This solves a bug where the point jumps to the top of the block that is currently rendering, if it's placed inside it.
Root cause
Each streaming chunk delete-and-reinserts the in-progress block, which displaces any markers inside that region to its start.
(point-marker)in the viewport branch andsave-mark-and-excursion/save-excursion(inagent-shell-ui-update-fragmentandshell-maker-with-auto-scroll-edit) all rely on markers, so cursor and viewport jumped to the block header when reading mid-stream.Fix
Switch to integer-based save/restore for point and window-start: inside
agent-shell-ui-update-fragment(covers the viewport flow) and aroundshell-maker-with-auto-scroll-editin the main shell branch (overrides shell-maker's brokensave-excursion).Fixes #454
Also related (though different issue) is the #552
Please view the change with ?w=1 (link). The change is not as big as the UI makes it to appear
Checklist
M-x checkdocandM-x byte-compile-file.