Repository navigation
Clear the region before snapping point to the live viewport - #701
Merged
Merged
Conversation
Switching to a live input mode snaps point to the end of the buffer. Three call sites do this and none cleared an active region first, so a selection stretched from its start to the prompt, and Emacs handed that grown span to the primary selection once the mark was deactivated. The kill ring is untouched and the grown region is never highlighted, which is why it went unnoticed. Leaving a terminal buffer and returning silently enters a read-only mode by two routes: the minibuffer-exit check sees point off the live cursor, and a buffer switch finalizes the mark activation. The next keystroke exits that mode and snaps. Entering char mode and leaving line mode run their own snap and were reached with the mark still active too. Deactivate at each of the three snaps. The custom exit branch keeps point where the user left it and needs no guard. The new tests read point from deactivate-mark-hook, which runs inside deactivate-mark after mark-active is cleared, so a deactivation that came after the snap reports the wrong position. They bind transient-mark-mode, which batch Emacs leaves nil. Fixes #698.
dakra
force-pushed
the
fix/readonly-exit-deactivates-mark
branch
from
September 18, 2026 07:47
c6dcbed to
e61851d
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 #698.
The bug
Switching to a live input mode snaps point to the end of the buffer. Three
call sites do this, and none of them cleared an active region first, so the
selection stretched from its start to the prompt. Emacs then published that
grown span to the primary selection when the mark was finally deactivated,
via
select-active-regions. The kill ring is untouched and the grown regionis never highlighted, which is why this stayed invisible.
The reporter hit it after leaving the buffer and returning, which silently
enters a read-only mode by two independent routes: the minibuffer-exit check
sees point off the live cursor, and a buffer switch finalizes the mark
activation. The next keystroke exits that mode and triggers the snap.
This is not specific to
ghostel-mouse-drag-input-modebeing nil. Under thedefault settings a mouse drag already enters copy mode, so drag-then-type
reproduces it with a stock configuration and no buffer switch.
The fix
deactivate-markimmediately before the snap, at each of the three sites:the read-only exit,
ghostel-semi-char-mode, andghostel-char-mode. Thelast two are the shared root for every entry direction, including entering
char mode from semi-char and leaving line mode.
The custom exit branch is left alone. It keeps point where the user put it,
and the one implementation that exists deactivates the mark itself.
Verification
Reproduced live in a sandboxed Emacs running a real shell under ghostel,
both reported routes and the default-configuration route, before and after.
Two ERT tests record point from
deactivate-mark-hook, which Emacs runsfrom inside
deactivate-markafter clearingmark-active, so a deactivationthat happened after the snap reports the wrong position. Both were confirmed
to fail against the unfixed source with the compiled files rebuilt between
runs.
make -j8 allpasses.