The IDE you know, rebuilt in Rust. IntelliJ IDEA–style keymap, tool windows and search-everywhere in a fast native app: editor, code insight, debugger, Git, terminal, database and HTTP clients for 60+ languages.
TypeScript code-editorcross-platformdapdatabase-clientdebuggerdesktop-appdeveloper-toolsgithttp-clientideintellijlsprusttauriterminal
perf(search): switch editors in the frame the Switcher closes (#2267)
l0ng-aif1c10f4d84b1
diff --git a/perf/budgets.json b/perf/budgets.jsonindex e8fd13052..5f3110ab2 100644--- a/perf/budgets.json+++ b/perf/budgets.json@@ -72,10 +72,11 @@"tabs.openSmallMs": 100,"tabs.switchP95Ms": 33,+ "tabs.switcherP50Ms": 33,"agentTabs.conversationNodes": 20000,"agentTabs.rowsAlwaysRendered": 0,- "agentTabs.switchP95Ms": 66,+ "agentTabs.switchP95Ms": 50,"agentTabs.switchMainThreadMs": 50,"agentTabs.switchTbtMs": 50,"agentTabs.scrollJumps": 0,diff --git a/perf/scenarios.ts b/perf/scenarios.tsindex 06a761cc2..feea3b968 100644--- a/perf/scenarios.ts+++ b/perf/scenarios.ts@@ -455,7 +455,21 @@ const tabs: Scenario = {switches.push(await h.measure(() => tab.click(), ".cm-content", `// tab-${i}`));}}- return { openSmallMs, ...latencySummary(switches, "switch") };+ // The Switcher (Ctrl+Tab) back and forth between the two most recent tabs.+ const before = await h.counters();+ const switcher: number[] = [];+ for (let i = 0; i < 10; i++) {+ const tag = i % 2 ? names.length - 1 : names.length - 2;+ switcher.push(await h.measure(() => h.pressAction("navigate.switcher"), ".cm-content", `// tab-${tag}`));+ await h.page.waitForTimeout(150);+ }+ const work = Harness.delta(before, await h.counters());+ return {+ openSmallMs,+ ...latencySummary(switches, "switch"),+ ...latencySummary(switcher, "switcher"),+ switcherMainThreadMs: work.taskMs / switcher.length,+ };},};diff --git a/src/features/search/__tests__/dialogs.test.tsx b/src/features/search/__tests__/dialogs.test.tsxindex 462678492..8b5f528ad 100644--- a/src/features/search/__tests__/dialogs.test.tsx+++ b/src/features/search/__tests__/dialogs.test.tsx@@ -55,7 +55,7 @@ vi.mock("../find/windowStore", async (orig) => ({const contributions = await import("@/workbench/contributions");const { commands } = await import("@/platform/ipc");const { RecentPopupsOverlay } = await import("../recent/RecentPopups");-const { showRecentPopup, hideRecentPopup, useRecentPopup } = await import("../recent/store");+const { cycleSwitcher, showRecentPopup, hideRecentPopup, useRecentPopup } = await import("../recent/store");const { openLocation } = await import("../common/open");const { usePlatform } = await import("@/platform/platformInfo");const { allActions } = await import("@/platform/actions");@@ -476,6 +476,42 @@ describe("Recent Files multi-selection", () => {});});+describe("Switcher", () => {+ afterEach(() => vi.restoreAllMocks());++ it("opens the selection when Ctrl is released, once the popup gave focus back, in the same task", async () => {+ const tab = (key: string, lastActive: number) => ({+ input: { kind: "agent-session", key },+ title: key,+ icon: "toolwindow-agents",+ lastActive,+ });+ const seen: Array<{ key: string; popup: boolean; focus: Element | null }> = [];+ vi.spyOn(commands, "recentFiles").mockResolvedValue({ status: "ok", data: [] });+ vi.spyOn(contributions, "maybeEditorService").mockReturnValue({+ openTabs: () => [tab("task-b", 2), tab("task-a", 1)],+ openPaths: () => [],+ activePath: () => null,+ openInput: async (input: { key: string }) => {+ seen.push({ key: input.key, popup: !!screen.queryByRole("dialog"), focus: document.activeElement });+ },+ } as unknown as import("@/workbench/contributions").EditorService);+ render(+ <>+ <button type="button">editor</button>+ <RecentPopupsOverlay />+ </>,+ );+ const editor = screen.getByRole("button", { name: "editor" });+ editor.focus();+ act(() => cycleSwitcher(1));+ await tick();+ expect(screen.getByRole("dialog", { name: "Switcher" })).toBeInTheDocument();+ act(() => void fireEvent.keyUp(window, { key: "Control" }));+ expect(seen).toEqual([{ key: "task-a", popup: false, focus: editor }]);+ });+});+describe("Find in Files dialog", () => {it("streams results and highlights the matches while replacing, as IDEA", async () => {render(<FindInFilesOverlay />);diff --git a/src/features/search/recent/RecentPopups.tsx b/src/features/search/recent/RecentPopups.tsxindex 18bc89d4a..68013c4a7 100644--- a/src/features/search/recent/RecentPopups.tsx+++ b/src/features/search/recent/RecentPopups.tsx@@ -1,5 +1,6 @@import { useFilePresentation } from "@/platform/filePresentation";import { useEffect, useMemo, useRef, useState, type KeyboardEvent, type MouseEvent as ReactMouseEvent } from "react";+import { flushSync } from "react-dom";import clsx from "clsx";import { editorsFor, getNavigationHistory } from "@/editor/api";import { call, commands, type OutlineItem } from "@/platform/ipc";@@ -61,10 +62,13 @@ export function RecentPopupsOverlay() {const NAV_KEYS = ["ArrowDown", "ArrowUp", "PageDown", "PageUp"];-/** Defers work until the dialog unmounted and restored focus. */+/**+ * Runs `fn` once the dialog has unmounted and given focus back, in the same frame: the+ * popup closing and what it opens paint together, without a frame of the old editor between.+ */const afterClose = (fn: () => void) => {- hideRecentPopup();- setTimeout(fn, 0);+ flushSync(hideRecentPopup);+ fn();};// ---------------------------------------------------------------------------