mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-25 18:16:32 +00:00
fix: retain filtered paste drafts and invalidate urgent input ownership
This commit is contained in:
1 parent
47f5077054
commit
4b5103cf6a
5 files changed
+56
-18
No files matched your search
@@ -499,9 +499,10 @@ test("paced recording uses its captured prefix and never imports text typed whil
|
||||
steps.length = 0;
|
||||
recorder.recordInput("prefix for a dropped first line");
|
||||
const lineRecorder = recorder.captureSubmittedLineRecorder()!;
|
||||
await lineRecorder("second was sent");
|
||||
await lineRecorder("second was sent", { consumePendingInput: false });
|
||||
await recorder.recordEnter();
|
||||
});
|
||||
assert.deepEqual(steps.filter(step => step.type === "send").map(step => step.value), ["second was sent"]);
|
||||
assert.deepEqual(steps.filter(step => step.type === "send").map(step => step.value), ["second was sent", "prefix for a dropped first line"]);
|
||||
} finally {
|
||||
await act(async () => renderer.unmount());
|
||||
}
|
||||
|
||||
@@ -247,15 +247,15 @@ export function useScriptRecorder(sessionId: string | undefined) {
|
||||
const isCurrent = () => generation === recordingGenerationRef.current
|
||||
&& sid === sessionIdRef.current && isRecordingRef.current
|
||||
&& !isPausedRef.current && !isStoppingRef.current;
|
||||
return (line: string, options?: { sensitive?: boolean; includePendingInput?: boolean }): Promise<void> => {
|
||||
return (line: string, options?: { sensitive?: boolean; includePendingInput?: boolean; consumePendingInput?: boolean }): Promise<void> => {
|
||||
// Capturing a batch is not a write. Retain its prefix if no receipt
|
||||
// arrives; on the first write remove only the still-owned prefix.
|
||||
if (!consumed && generation === recordingGenerationRef.current && sid === sessionIdRef.current
|
||||
// arrives; only its prefixed first line can consume the still-owned draft.
|
||||
if (options?.consumePendingInput !== false && !consumed && generation === recordingGenerationRef.current && sid === sessionIdRef.current
|
||||
&& revision === inputRevisionRef.current && inputBufferRef.current.startsWith(pendingInput)) {
|
||||
inputBufferRef.current = inputBufferRef.current.slice(pendingInput.length);
|
||||
inputRevisionRef.current += 1;
|
||||
}
|
||||
consumed = true;
|
||||
if (options?.consumePendingInput !== false) consumed = true;
|
||||
if (!isCurrent()) return Promise.resolve();
|
||||
return recordEnter({ sensitive: options?.sensitive, submittedLine: options?.includePendingInput ? `${pendingInput}${line}` : line });
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user