mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-04-29 04:00:36 +00:00
fix: try to fix test case failures on Windows
This commit is contained in:
parent
c093bed38c
commit
35efa9f04a
4 changed files with 78 additions and 51 deletions
|
|
@ -69,10 +69,12 @@ export function useKeypressContext() {
|
|||
export function KeypressProvider({
|
||||
children,
|
||||
kittyProtocolEnabled,
|
||||
pasteWorkaround = false,
|
||||
config,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
children?: React.ReactNode;
|
||||
kittyProtocolEnabled: boolean;
|
||||
pasteWorkaround?: boolean;
|
||||
config?: Config;
|
||||
}) {
|
||||
const { stdin, setRawMode } = useStdin();
|
||||
|
|
@ -97,18 +99,8 @@ export function KeypressProvider({
|
|||
|
||||
const keypressStream = new PassThrough();
|
||||
let usePassthrough = false;
|
||||
const nodeMajorVersion = parseInt(process.versions.node.split('.')[0], 10);
|
||||
const isWindows = process.platform === 'win32';
|
||||
// On Windows, Node's readline keypress stream often loses bracketed paste
|
||||
// boundaries, causing multi-line pastes to be delivered as plain Return
|
||||
// key events. This leads to accidental submits on Enter within pasted text.
|
||||
// Force passthrough on Windows to parse raw bytes and detect ESC[200~...201~.
|
||||
if (
|
||||
nodeMajorVersion < 20 ||
|
||||
isWindows ||
|
||||
process.env['PASTE_WORKAROUND'] === '1' ||
|
||||
process.env['PASTE_WORKAROUND'] === 'true'
|
||||
) {
|
||||
// Use passthrough mode when pasteWorkaround is enabled,
|
||||
if (pasteWorkaround) {
|
||||
usePassthrough = true;
|
||||
}
|
||||
|
||||
|
|
@ -500,7 +492,14 @@ export function KeypressProvider({
|
|||
pasteBuffer = Buffer.alloc(0);
|
||||
}
|
||||
};
|
||||
}, [stdin, setRawMode, kittyProtocolEnabled, config, subscribers]);
|
||||
}, [
|
||||
stdin,
|
||||
setRawMode,
|
||||
kittyProtocolEnabled,
|
||||
pasteWorkaround,
|
||||
config,
|
||||
subscribers,
|
||||
]);
|
||||
|
||||
return (
|
||||
<KeypressContext.Provider value={{ subscribe, unsubscribe }}>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue