Файли
openidea/src/platform/localDiagnostics.ts
T
rohitkumardandaтаrohitdanda 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 <[email protected]>
2026-11-12 02:09:24 +08:00

21 рядки
771 B
TypeScript

/**
* Diagnostics computed in the UI (Typo, file references, SQL inspections), as
* full per-(file, producer) replacements like the backend's `diagnostics`
* event, so the Problems view sees them as well as the editor.
*/
import type { Diagnostic } from "@/bindings";
import { notifyEach } from "./listeners";
type Listener = (path: string, producer: string, items: readonly Diagnostic[]) => void;
const listeners = new Set<Listener>();
export function publishLocalDiagnostics(path: string, producer: string, items: readonly Diagnostic[]) {
notifyEach(listeners, (l) => l(path, producer, items), "local diagnostics");
}
export function onLocalDiagnostics(listener: Listener): () => void {
listeners.add(listener);
return () => listeners.delete(listener);
}