diff --git a/CHANGES.md b/CHANGES.md index 8ae91ffbf..f3b92f305 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -60,6 +60,8 @@ - Fix document syncing (#1278, #1280, fixes #1207) +- Stop generating inlay hints on generated code (#1290) + # 1.17.0 ## Fixes diff --git a/ocaml-lsp-server/src/inlay_hints.ml b/ocaml-lsp-server/src/inlay_hints.ml index 3f7106b09..b0c06c10e 100644 --- a/ocaml-lsp-server/src/inlay_hints.ml +++ b/ocaml-lsp-server/src/inlay_hints.ml @@ -56,6 +56,8 @@ let hint_binding_iter ?(hint_let_bindings = false) | Texp_match (expr, cases, _) -> iter.expr iter expr; List.iter cases ~f:(case hint_pattern_variables iter) + (* Stop iterating when we see a ghost location to avoid annotating generated code *) + | _ when e.exp_loc.loc_ghost && not inside_test -> () | _ -> I.default_iterator.expr iter e in @@ -65,6 +67,8 @@ let hint_binding_iter ?(hint_let_bindings = false) | Typedtree.Tstr_value (_, vbs) -> List.iter vbs ~f:(fun (vb : Typedtree.value_binding) -> expr iter vb.vb_expr) + (* Stop iterating when we see a ghost location to avoid annotating generated code *) + | _ when item.str_loc.loc_ghost && not inside_test -> () | _ -> I.default_iterator.structure_item iter item in let pat (type k) iter (pat : k Typedtree.general_pattern) =