this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix CodeMirror errors: accumulate output, clamp lint, skip formatter

Three changes to address CodeMirror RangeError and cm-gap issues:

1. jtw_client: Accumulate per-phrase output and emit as single
Top_response at cell end, instead of per-phrase Top_response_at.
Eliminates mid-document widget decorations that cause cm-gap
artifacts in CodeMirror's virtual rendering.

2. merlin_codemirror: Clamp lint diagnostic positions to current
document length. The doc can change between query send and
response arrival (e.g., formatter), making positions stale.

3. cell.ml: Skip formatter for run_on=load cells. The formatter
can change document length, creating changesets that invalidate
decoration positions from concurrent eval responses.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

+18 -14
+1 -1
src/cell.ml
··· 506 506 | Some cm -> 507 507 Editor.set_source cm effective_doc; 508 508 invalidate_from ~editor; 509 - if effective_doc = doc then 509 + if effective_doc = doc && editor.run_on = `Click then 510 510 editor.fmt_fn ~id:editor.id doc 511 511 | None -> 512 512 invalidate_from ~editor);
+17 -13
src/jtw_client.cppo.ml
··· 193 193 let stream = Jtw.eval_stream t.client code in 194 194 Lwt.async (fun () -> 195 195 Lwt.catch (fun () -> 196 + let acc = ref [] in 196 197 Lwt_stream.iter (function 197 - | Jtw.Phrase { loc; caml_ppf; _ } -> 198 + | Jtw.Phrase { loc = _; caml_ppf; _ } -> 199 + if caml_ppf <> "" then 200 + acc := X_protocol.Meta caml_ppf :: !acc 201 + | Jtw.Done { stdout; stderr; caml_ppf; _ } -> 202 + let outputs = List.rev !acc in 198 203 let outputs = 199 - if caml_ppf <> "" then [X_protocol.Meta caml_ppf] else [] 204 + if caml_ppf <> "" then outputs @ [X_protocol.Meta caml_ppf] 205 + else outputs 200 206 in 201 - if outputs <> [] then 202 - respond t (X_protocol.Top_response_at (id, loc, outputs)) 203 - | Jtw.Done { stdout; stderr; caml_ppf; _ } -> 204 - let outputs = ref [] in 205 - if caml_ppf <> "" then 206 - outputs := X_protocol.Meta caml_ppf :: !outputs; 207 - if stdout <> "" then 208 - outputs := X_protocol.Stdout stdout :: !outputs; 209 - if stderr <> "" then 210 - outputs := X_protocol.Stderr stderr :: !outputs; 211 - respond t (X_protocol.Top_response (id, List.rev !outputs)) 207 + let outputs = 208 + if stdout <> "" then outputs @ [X_protocol.Stdout stdout] 209 + else outputs 210 + in 211 + let outputs = 212 + if stderr <> "" then outputs @ [X_protocol.Stderr stderr] 213 + else outputs 214 + in 215 + respond t (X_protocol.Top_response (id, outputs)) 212 216 | Jtw.Error msg -> 213 217 respond t (X_protocol.Top_response 214 218 (id, [X_protocol.Stderr msg]))