fix(editor): improve result navigation and scrolling performance
This commit is contained in:
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();
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user