Skip CRLF normalization on alt screen#306
Merged
Merged
Conversation
Apps that use the alternate screen (tmux, vim, less) emit VT-correct sequences where a bare `\n` means LF (cursor down, column preserved). Normalizing those to `\r\n` corrupts their layout. Skip the bare-LF -> CRLF conversion whenever the active screen is the alternate. Detection uses `terminal.screens.active_key == .alternate` so all three alt-screen entry modes (DECSET 47 / 1047 / 1049) are covered uniformly.
Owner
|
@emil-e you have a quick look as well but lgtm |
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.
Summary
Skip bare-LF -> CRLF normalization while the terminal is on the alternate screen.
Why
Emacs PTYs lack
ONLCR, so the module inserts\rbefore each bare\n- correct for line-oriented output on the primary screen. But alt-screen apps (tmux, vim, less) emit VT-correct LF (cursor down, column preserved); normalizing those to\r\ncorrupts their layout.Fix
Skip the conversion when the active screen is the alternate one:
Detection via
screens.active_keycovers all three alt-screen entry modes (DECSET 47 / 1047 / 1049) uniformly.last_input_was_cris still maintained so a CRLF pair split across writes isn't mis-normalized into\r\r\n.Demo
Before
before.mp4
After
after.mp4