mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-19 00:10:00 +00:00
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>
21 lines
723 B
TypeScript
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();
|
|
});
|