mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-11 08:42:45 +00:00
fix: address Codex review on PR #3409
This commit is contained in:
1 parent
c0ed0c3e39
commit
61a2d50e9f
2 files changed
+65
-15
No files matched your search
@@ -1029,3 +1029,33 @@ test("multi-character plain text goes out as per-character writes (#3077)", asyn
|
||||
assert.match(writeSite, /ctx\.onOutputTriggerUserInputRef\?\.current\?\.\(outData\)/);
|
||||
assert.match(source, /onBroadcastInput\?\.\(broadcastData, ctx\.sessionId\)/);
|
||||
});
|
||||
|
||||
test("⌘. interrupt press is keyed apart from an outstanding physical KeyC press (#3409)", async () => {
|
||||
const { readFileSync } = await import("node:fs");
|
||||
const source = readFileSync(new URL("./createXTermRuntime.ts", import.meta.url), "utf8");
|
||||
|
||||
// The normalized Ctrl+C press shares its event identity with a possibly
|
||||
// outstanding physical KeyC press, so it must be recorded under a dedicated
|
||||
// map key: upserting under "KeyC" replaced the held key's press and the
|
||||
// Period keyup deleted that shared entry while C was still down.
|
||||
assert.match(
|
||||
source,
|
||||
/const pressIdentity =\s*macCommandPeriodInterrupt && identity !== kittyKeyIdentity\(e\)\s*\?\s*kittyNormalizedPressIdentity\(identity\)\s*:\s*identity,?/,
|
||||
);
|
||||
assert.match(source, /kittyNormalizedPressAliases\.set\(kittyKeyIdentity\(e\), pressIdentity\)/);
|
||||
assert.match(
|
||||
source,
|
||||
/upsertKittyKeyboardForwardedPress\(\s*kittyForwardedKeys,\s*pressIdentity,/,
|
||||
);
|
||||
assert.match(
|
||||
source,
|
||||
/upsertKittyKeyboardForwardedPress\(\s*broadcastForwardedKeys,\s*pressIdentity,/,
|
||||
);
|
||||
// The aliased Period keyup releases the interrupt press under its dedicated
|
||||
// key, leaving the physical KeyC press entry intact.
|
||||
assert.match(source, /aliasedReleaseIdentity = aliasedRelease\.identity/);
|
||||
assert.match(
|
||||
source,
|
||||
/releaseForwardedKittyPress\(toKittyKeyboardEvent\(releaseEvent\), aliasedReleaseIdentity\)/,
|
||||
);
|
||||
});
|
||||
@@ -1490,9 +1490,13 @@ export const createXTermRuntime = (ctx: CreateXTermRuntimeContext): XTermRuntime
|
||||
const broadcastForwardedKeys = new Map<string, KittyKeyboardForwardedPress>();
|
||||
const win32BroadcastForwardedKeys = new Map<string, KittyKeyboardForwardedPress>();
|
||||
// ⌘. interrupt presses are recorded under their normalized Ctrl+C identity
|
||||
// (KeyC) so broadcast legacy pairing stays matched (#3408). Map the physical
|
||||
// chord identity (Period) to it so the later keyup can pair the release.
|
||||
// (KeyC) so broadcast legacy pairing stays matched (#3408), but under a
|
||||
// dedicated map key so they cannot clobber an outstanding physical KeyC
|
||||
// press; map the physical chord identity (Period) to it so the later keyup
|
||||
// can pair the release.
|
||||
const kittyNormalizedPressAliases = new Map<string, string>();
|
||||
const kittyNormalizedPressIdentity = (identity: string): string =>
|
||||
`${identity} | ||||