From 6a00a7e9a9b27c1ccc02792d2b8a49006d9edf43 Mon Sep 17 00:00:00 2001 From: Aaron Bauer Date: Tue, 21 May 2024 10:29:33 -0400 Subject: [PATCH 1/3] disable inlay hints under ghost location --- ocaml-lsp-server/src/inlay_hints.ml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ocaml-lsp-server/src/inlay_hints.ml b/ocaml-lsp-server/src/inlay_hints.ml index 3f7106b09..a416e0fa4 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 -> () | _ -> 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 -> () | _ -> I.default_iterator.structure_item iter item in let pat (type k) iter (pat : k Typedtree.general_pattern) = From c068814b77e8ba29e12422aaacceea65c6029574 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Wed, 29 May 2024 10:43:48 -0600 Subject: [PATCH 2/3] _ Signed-off-by: Rudi Grinberg --- ocaml-lsp-server/src/inlay_hints.ml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ocaml-lsp-server/src/inlay_hints.ml b/ocaml-lsp-server/src/inlay_hints.ml index a416e0fa4..b0c06c10e 100644 --- a/ocaml-lsp-server/src/inlay_hints.ml +++ b/ocaml-lsp-server/src/inlay_hints.ml @@ -57,7 +57,7 @@ let hint_binding_iter ?(hint_let_bindings = false) 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 -> () + | _ when e.exp_loc.loc_ghost && not inside_test -> () | _ -> I.default_iterator.expr iter e in @@ -68,7 +68,7 @@ let hint_binding_iter ?(hint_let_bindings = false) 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 -> () + | _ 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) = From 29411e311527536739e6112810a39a5a812a4d7e Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Wed, 29 May 2024 10:44:20 -0600 Subject: [PATCH 3/3] _ Signed-off-by: Rudi Grinberg --- CHANGES.md | 2 ++ 1 file changed, 2 insertions(+) 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