Repository navigation
aio(feat[session]): Add mode-aware send_line() - #214
Merged
Merged
Conversation
why:
Line-oriented terminal prompts had to coordinate paste() and
send_key("enter") separately, risking partial writes under buffer limits
or hardcoded carriage returns that break ?2004 and Kitty keyboard modes.
what:
- Add _encode_line_payload() in libvt.input sharing paste control checks
while rejecting embedded CR/LF unless sanitize=True and omitting empty
?2004 brackets.
- Add send_line(text, /, *, sanitize=False) to AsyncSession,
_SessionCore (AsyncTerminalStream, PtySession), and TerminalProcess,
encoding text and Enter atomically onto the outbound write queue.
- Add stream, POSIX PTY, and subprocess tests, update
docs/topics/sync-and-asyncio.md and docs/api/contrib/subprocess.md,
and record the entry in CHANGES.
Fixes #121
35 of 38 tasks
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.
Summary
Add a mode-aware
send_line(text, /, *, sanitize=False)method toAsyncSession,AsyncTerminalStream,PtySession, and synchronousTerminalProcess.Changes
libvt.input._is_disallowed_paste_cp()and add_encode_line_payload()to wrap non-empty payloads in?2004brackets when active, omit empty brackets when empty or sanitized to empty, and always reject embedded CR/LF and unsafe controls withUnsafePasteErrorunlesssanitize=True.send_line(text, /, *, sanitize=False)toAsyncSessionand_SessionCore(inherited byAsyncTerminalStreamandPtySession), encoding the line payload andKeyEvent("enter")atomically onto the single-FIFO outbound write queue so buffer overflow raisesBufferErrorwithout queuing partial bytes.TerminalProcess.send_line(text, /, *, sanitize=False)inlibvt.contrib.subprocessdelegating to the underlying session (POSIX PTY and Windows ConPTY).is_safe_paste, exact split-write buffer boundaries, Kitty>8u/>31u, and concurrentaclose()ECANCELEDcancellation), docs updates, and aCHANGESentry.Fixes #121