From 0b97912270a1e8b504bfc9ea1cf0aaf02873200d Mon Sep 17 00:00:00 2001 From: Michael Gartner Date: Tue, 30 Jun 2026 16:49:21 -0600 Subject: [PATCH] Reduce quick switcher startup work --- src/quickSwitcher.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/quickSwitcher.tsx b/src/quickSwitcher.tsx index 074d12e..5dd09f5 100644 --- a/src/quickSwitcher.tsx +++ b/src/quickSwitcher.tsx @@ -150,6 +150,7 @@ const initializeQuickSwitcher = ({ }), }); let isDialogOpen = false; + let hasRenderedDialog = false; const persistBookmarks = (): void => { void extensionAPI.settings.set(BOOKMARKS_SETTING_KEY, bookmarks); @@ -157,10 +158,13 @@ const initializeQuickSwitcher = ({ const closeDialog = (): void => { isDialogOpen = false; - render(); + if (hasRenderedDialog) { + render(); + } }; const render = (): void => { + hasRenderedDialog = true; ReactDOM.render( undefined); }; - persistBookmarks(); document.addEventListener("keydown", onDocumentKeyDown, true); registerCommand(); - render(); return { getBookmarks: (): QuickSwitcherBookmark[] => bookmarks, @@ -240,7 +242,9 @@ const initializeQuickSwitcher = ({ setBookmarks: (nextBookmarks: QuickSwitcherBookmark[]): void => { bookmarks = sanitizeBookmarks({ bookmarks: nextBookmarks }); persistBookmarks(); - render(); + if (hasRenderedDialog) { + render(); + } }, unload: (): void => { closeDialog();