perf: debounce rerender calls with queueMicrotask to coalesce rapid updates
This commit is contained in:
13
index.ts
13
index.ts
@@ -124,10 +124,19 @@ export default function piStatusbarExtension(pi: ExtensionAPI) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let rerenderScheduled = false;
|
||||||
function rerender(ctx: any) {
|
function rerender(ctx: any) {
|
||||||
latestCtx = ctx;
|
latestCtx = ctx;
|
||||||
requestRender?.();
|
if (rerenderScheduled) return;
|
||||||
if (ctx.hasUI) ctx.ui.setStatus("pi-statusbar", undefined);
|
rerenderScheduled = true;
|
||||||
|
|
||||||
|
// Debounce Render - Coalesce rapid rerender calls into a single pass.
|
||||||
|
queueMicrotask(() => {
|
||||||
|
rerenderScheduled = false;
|
||||||
|
requestRender?.();
|
||||||
|
const current = latestCtx;
|
||||||
|
if (current?.hasUI) current.ui.setStatus("pi-statusbar", undefined);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function installFooter(ctx: any) {
|
function installFooter(ctx: any) {
|
||||||
|
|||||||
Reference in New Issue
Block a user