From fd26c04b5cd386e661b60f36f0d7386e2740880e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kan=20Nilsson?= Date: Mon, 7 Oct 2024 22:55:58 +0200 Subject: [PATCH] Don't show inlay hint for _Var if arg is named Var (#1558) --- apps/els_lsp/src/els_inlay_hint_provider.erl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/apps/els_lsp/src/els_inlay_hint_provider.erl b/apps/els_lsp/src/els_inlay_hint_provider.erl index 2c3bfb3c..05708397 100644 --- a/apps/els_lsp/src/els_inlay_hint_provider.erl +++ b/apps/els_lsp/src/els_inlay_hint_provider.erl @@ -136,7 +136,17 @@ should_show_arg_hint(_Name, undefined) -> should_show_arg_hint(undefined, _Name) -> true; should_show_arg_hint(Name, DefArgName) -> - strip_trailing_digits(Name) /= strip_trailing_digits(DefArgName). + normalize(Name) /= normalize(DefArgName). + +-spec normalize(string()) -> string(). +normalize(String) -> + remove_leading_underscore( + strip_trailing_digits(String) + ). + +-spec remove_leading_underscore(string()) -> string(). +remove_leading_underscore(String) -> + string:trim(String, leading, "_"). -spec strip_trailing_digits(string()) -> string(). strip_trailing_digits(String) ->