fix(editor): improve result navigation and scrolling performance

This commit is contained in:
二丫讲梵 authored and GitHub committed 2026-09-11 10:51:41 +08:00
1 parent 14298b31a8
commit 15d451d43a
17 files changed
+392 -36

No files matched your search

@@ -0,0 +1,23 @@
/** Keep nonvisual work off continuous typing/scrolling, with an explicit lifecycle flush. */
export function createDeferredEditorTask(run: () => void, delay: number) {
let timer: ReturnType<typeof setTimeout> | null = null;
function cancel() {
if (timer !== null) clearTimeout(timer);
timer = null;
}
return {
schedule() {
cancel();
timer = setTimeout(() => {
timer = null;
run();
}, delay);
},
cancel,
flush() {
if (timer === null) return;
cancel();
run();
},
};
}