Skip to content

Commit 0de0919

Browse files
feat(Sky): Bridge diagnostics to IMarkerService for visible editor markers
Add a new handler for `sky://diagnostics/changed` that translates Mountain's diagnostic events into the editor's `IMarkerService`. Without this bridge, diagnostic data from Cocoon's `vscode.languages.createDiagnosticCollection().set()` sits in Mountain's `DiagnosticsMap` but never renders as red squiggles in the editor or populates the Problems panel. The handler receives `{ owner, changedURIs: [{ uri, markers }] }` and calls `Markers.changeOne(owner, URI, markers)` for each entry - matching VS Code's `MainThreadDiagnostics` behavior where each `set()` call overwrites the previous diagnostic state. This enables language extension compile errors, lint warnings, and type errors to become visible in the editor UI.
1 parent a178c92 commit 0de0919

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

Source/Function/SkyBridge.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1932,6 +1932,49 @@ export async function InstallSkyBridge(): Promise<void> {
19321932
});
19331933
}
19341934

1935+
// ---- Diagnostics → IMarkerService bridge ----
1936+
// Mountain emits `sky://diagnostics/changed` after each `Diagnostic.Set`
1937+
// from Cocoon's `vscode.languages.createDiagnosticCollection().set(...)`.
1938+
// Without a renderer-side consumer that pushes into the workbench's
1939+
// `IMarkerService`, the data lands in Mountain's `DiagnosticsMap` but
1940+
// the editor never paints red squiggles and the Problems panel stays
1941+
// empty - every language extension's compile errors / lint warnings /
1942+
// type errors are invisible.
1943+
//
1944+
// Payload shape (from `DiagnosticProvider.SetDiagnostics`): `{ owner,
1945+
// changedURIs: [{ uri, markers }] }`. We translate per-URI marker
1946+
// arrays into `IMarkerService.changeOne(owner, URI, markers)` calls.
1947+
// `Markers.changeOne` REPLACES the marker set for that URI under the
1948+
// given owner - matching VS Code's `MainThreadDiagnostics` behaviour
1949+
// where each `set()` call overwrites the previous diagnostic state.
1950+
await Register("sky://diagnostics/changed", (Payload: any) => {
1951+
const Services = GetServices();
1952+
const Markers = (Services as any)?.Markers;
1953+
const URICtor = (Services as any)?.URI;
1954+
if (!Markers?.changeOne || !URICtor) return;
1955+
const Owner = String(Payload?.owner ?? "");
1956+
const Changed = Array.isArray(Payload?.changedURIs)
1957+
? Payload.changedURIs
1958+
: [];
1959+
for (const Entry of Changed) {
1960+
try {
1961+
const Uri = Entry?.uri;
1962+
const Markers_ = Array.isArray(Entry?.markers) ? Entry.markers : [];
1963+
if (!Uri) continue;
1964+
const RealUri =
1965+
typeof Uri === "string"
1966+
? URICtor.parse(Uri)
1967+
: Uri && typeof (Uri as any).with === "function"
1968+
? Uri
1969+
: URICtor.from(Uri);
1970+
Markers.changeOne(Owner, RealUri, Markers_);
1971+
} catch (Error) {
1972+
// Swallow - one bad entry must not stop the rest.
1973+
void Error;
1974+
}
1975+
}
1976+
});
1977+
19351978
// ---- Tree-view data bridge ----
19361979
// Two-way wire so extension-registered tree views actually render:
19371980
//

0 commit comments

Comments
 (0)