Repository navigation
fix(pty): fix a batch of Windows terminal and PTY daemon issues #66793
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from 4 commits
f460458
913455d
b4b1000
ac1e814
8862ebb
5677b1a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,7 +22,7 @@ import { | |
| import type { TerminalProps } from "./props" | ||
| import { disposeIfDisposable, getHoveredLinkText, setOptionIfSupported } from "./runtime-adapters" | ||
| import { terminalLinkLabel } from "./hover-label" | ||
| import { consumeTerminalMetaKey, terminalKeyInput, terminalLinkTarget } from "./terminal-key-event" | ||
| import { consumeTerminalMetaKey, terminalKeyInput, terminalScrollKey, terminalLinkTarget } from "./terminal-key-event" | ||
| import { TerminalQuote } from "./quote" | ||
|
|
||
| type TerminalColors = { | ||
|
|
@@ -116,7 +116,9 @@ const useTerminalUiBindings = (input: { | |
|
|
||
| event.preventDefault() | ||
| event.stopPropagation() | ||
| input.term.paste(text) | ||
| // A terminal sends Enter as CR. Windows clipboards end lines with CR LF, which PowerShell reads as Enter followed by | ||
| // a stray line feed, so send each line break as one CR, as other terminals do. | ||
| input.term.paste(text.replace(/\r?\n/g, "\r")) | ||
| } | ||
|
|
||
| const handleTextareaFocus = () => { | ||
|
|
@@ -476,6 +478,22 @@ export const Terminal = (props: TerminalProps) => { | |
| return true | ||
| } | ||
|
|
||
| // Programs on the alternate screen (vim, less) keep these keys; on the normal screen they move through the | ||
| // scrollback, as in other terminals. | ||
| const scroll = terminalScrollKey(event) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the normal screen this always takes Shift+Home and Shift+End. PowerShell's line editor (PSReadLine), the main Windows shell, binds them by default to select to the start and end of the line, and fish and zsh users sometimes bind them too. Windows Terminal leaves Shift+Home and Shift+End to the shell and only scrolls with Ctrl+Shift+Home and Ctrl+Shift+End. Shift+PageUp and Shift+PageDown look safe; Home and End could be limited to Ctrl+Shift, or not taken at all. |
||
|
|
||
| if (scroll && !t.wasmTerm?.isAlternateScreen()) { | ||
| if (scroll === "page-up") t.scrollPages(-1) | ||
|
|
||
| if (scroll === "page-down") t.scrollPages(1) | ||
|
|
||
| if (scroll === "top") t.scrollToTop() | ||
|
|
||
| if (scroll === "bottom") t.scrollToBottom() | ||
|
|
||
| return true | ||
| } | ||
|
|
||
| if (event.ctrlKey && event.shiftKey && !event.metaKey && key === "c") { | ||
| document.execCommand("copy") | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The log goes in
root, next to the daemon's runtime directories. That breakscreates two persistent terminals for one session through the client APIinpackages/server/test/persistent-pty.test.ts: it readsfs.readdir(fixture.directory)and expects exactly one entry, the daemon directory, and now getsopencode-pty.logas well. It passes on the base and fails with this PR. Either update that test or move the log somewhere the runtime-root listing doesn't see. Separately, the 1 MB check only runs when a daemon is spawned, so a long-lived daemon can still grow the file without limit.