Files
openidea/src/platform/navigationModifier.test.ts
T
rohitkumardandaandrohitdanda cb5e7081fa fix(platform): keep delivering IDE events after one handler throws (#2790)
Broadcasts called their listeners in a bare loop, so one throwing handler kept the rest (including the catch-all "*" IDE event handlers) from seeing the event. The IDE event bus, local diagnostics, endpoint-change and navigation-modifier broadcasts now go through `notifyEach`, which logs a throwing listener and moves on. `onIdeEvent` wraps each subscription so unsubscribing one of two identical handlers keeps the other.

Co-authored-by: rohitdanda <10144914+rohitdanda@users.noreply.github.com>
2026-11-12 02:09:24 +08:00

21 lines
723 B
TypeScript

import { afterEach, expect, it, vi } from "vitest";
import { isMacHost } from "./keymap";
import { onNavigationModifier, resetNavigationModifier } from "./navigationModifier";
afterEach(() => {
resetNavigationModifier();
vi.restoreAllMocks();
});
it("keeps notifying navigation modifier listeners after one throws", () => {
const error = vi.spyOn(console, "error").mockImplementation(() => {});
const second = vi.fn();
onNavigationModifier(() => {
throw new Error("boom");
});
onNavigationModifier(second);
window.dispatchEvent(new KeyboardEvent("keydown", isMacHost() ? { metaKey: true } : { ctrlKey: true }));
expect(second).toHaveBeenCalledWith(true);
expect(error).toHaveBeenCalledOnce();
});