mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-16 20:11:08 +00:00
* fix(#2783): automated Cursor CLI fix * fix: address Codex review on PR #2838 * fix: address Codex review on PR #2838 * fix: address Codex review on PR #2838 * fix: address Codex review on PR #2838 * fix: address Codex review on PR #2838 * fix: address Codex review on PR #2838 * fix: address Codex review on PR #2838 * fix: address Codex review on PR #2838 * fix: address Codex review on PR #2838 * fix: address Codex review on PR #2838 * fix: address Codex review on PR #2838 * fix: address Codex review on PR #2838 * fix: address Codex review on PR #2838 * fix: address Codex review on PR #2838 * fix: address Codex review on PR #2838 * fix: address Codex review on PR #2838 * fix: address Codex review on PR #2838 * fix: address Codex review on PR #2838 * fix: address Codex review on PR #2838 * fix: address Codex review on PR #2838 * fix: address Codex review on PR #2838 * fix: address Codex review on PR #2838 * fix: address Codex review on PR #2838 * fix: address Codex review on PR #2838 * fix: address Codex review on PR #2838 * fix: address Codex review on PR #2838 * fix: address Codex review on PR #2838 * fix: address Codex review on PR #2838 * fix: address Codex review on PR #2838 * fix: address Codex review on PR #2838 * fix: address Codex review on PR #2838 * fix: address Codex review on PR #2838 * fix: address Codex review on PR #2838 * fix: address Codex review on PR #2838 * fix: address Codex review on PR #2838 * fix: address Codex review on PR #2838 * fix: address Codex review on PR #2838 * fix: address Codex review on PR #2838 * fix: address Codex review on PR #2838 * fix: address Codex review on PR #2838 * fix(notes): slim paste recovery after Codex review bloat Collapse the 40-round Lexical serialization/domain rewrite back to the original caret-loss recovery: intercept without selection, setMarkdown merge when there is no caret, and keep insertMarkdown when there is one. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(notes): harden paste recovery against stale commits Invalidate deferred paste commits on note switch/unmount, merge from live editor markdown, and poll briefly for muted onChange instead of appending. Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: netcatty-bot <308658023+netcatty-bot@users.noreply.github.com> Co-authored-by: bincxz <16399091+binaricat@users.noreply.github.com> Co-authored-by: Cursor <cursoragent@cursor.com>
94 lines
3.2 KiB
TypeScript
94 lines
3.2 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import { readFileSync } from "node:fs";
|
|
import test from "node:test";
|
|
|
|
import {
|
|
mergeNoteMarkdownDocumentPaste,
|
|
shouldInterceptNoteMarkdownPaste,
|
|
} from "./InlineMarkdownEditor.tsx";
|
|
|
|
test("markdown paste intercepts structured clipboard text in edit mode even without a Lexical selection", () => {
|
|
assert.equal(
|
|
shouldInterceptNoteMarkdownPaste({
|
|
editorMode: "edit",
|
|
pasteInsideCodeBlock: false,
|
|
clipboardText: "# Heading\n\n- item",
|
|
canInsertMarkdownAtSelection: true,
|
|
}),
|
|
true,
|
|
);
|
|
// After a prior insertMarkdown clears the caret, continuous paste must still
|
|
// be recoverable via document setMarkdown rather than a swallowed preventDefault.
|
|
assert.equal(
|
|
shouldInterceptNoteMarkdownPaste({
|
|
editorMode: "edit",
|
|
pasteInsideCodeBlock: false,
|
|
clipboardText: "# Heading\n\n- item",
|
|
canInsertMarkdownAtSelection: false,
|
|
}),
|
|
true,
|
|
);
|
|
assert.equal(
|
|
shouldInterceptNoteMarkdownPaste({
|
|
editorMode: "preview",
|
|
pasteInsideCodeBlock: false,
|
|
clipboardText: "# Heading\n\n- item",
|
|
canInsertMarkdownAtSelection: true,
|
|
}),
|
|
false,
|
|
);
|
|
});
|
|
|
|
test("document paste merge preserves first-line indentation and appends after current body", () => {
|
|
assert.equal(
|
|
mergeNoteMarkdownDocumentPaste("Existing note", "# Pasted\n\n- item"),
|
|
"Existing note\n\n# Pasted\n\n- item",
|
|
);
|
|
assert.equal(
|
|
mergeNoteMarkdownDocumentPaste(" ", "# Only paste"),
|
|
"# Only paste",
|
|
);
|
|
assert.equal(
|
|
mergeNoteMarkdownDocumentPaste("- parent", " - child"),
|
|
"- parent\n\n - child",
|
|
);
|
|
assert.equal(
|
|
mergeNoteMarkdownDocumentPaste("Existing", "\n\n# Pasted\n"),
|
|
"Existing\n\n# Pasted",
|
|
);
|
|
});
|
|
|
|
test("InlineMarkdownEditor only preventDefaults markdown paste after a successful intercept guard", () => {
|
|
const source = readFileSync(new URL("./InlineMarkdownEditor.tsx", import.meta.url), "utf8");
|
|
|
|
assert.match(source, /shouldInterceptNoteMarkdownPaste/);
|
|
assert.match(source, /hasActiveLexicalTextSelection/);
|
|
assert.match(source, /mergeNoteMarkdownDocumentPaste/);
|
|
assert.match(source, /setMarkdown\(/);
|
|
assert.match(source, /canInsertAtSelection/);
|
|
assert.match(
|
|
source,
|
|
/shouldInterceptNoteMarkdownPaste\([\s\S]*?\)[\s\S]*?event\.preventDefault\(\)/,
|
|
);
|
|
assert.match(
|
|
source,
|
|
/if \(\s*!shouldInterceptNoteMarkdownPaste\([\s\S]*?\)\s*\{\s*return;\s*\}/,
|
|
);
|
|
// Live selection must keep insertMarkdown; document merge is the no-selection path only.
|
|
assert.match(source, /if\s*\(\s*!canInsertAtSelection\s*\)\s*\{\s*applyDocumentPaste\(\);/);
|
|
assert.match(source, /editor\.insertMarkdown\(markdown\)/);
|
|
assert.match(source, /pasteRecoveryGenerationRef/);
|
|
assert.match(source, /tryCommitSettledPaste/);
|
|
assert.match(source, /editor\.getMarkdown\(\)/);
|
|
// Selection-path recovery must not re-enter applyDocumentPaste (duplicate / stale-note risk).
|
|
assert.doesNotMatch(
|
|
source,
|
|
/insertMarkdown\(markdown\);[\s\S]*applyDocumentPaste\(\)/,
|
|
);
|
|
// Document merge must read live editor markdown, not only the possibly-stale ref.
|
|
assert.match(
|
|
source,
|
|
/const currentMarkdown = editor\.getMarkdown\(\);[\s\S]*mergeNoteMarkdownDocumentPaste\(currentMarkdown, markdown\)/,
|
|
);
|
|
});
|