From ba41dd7f14726c26e60cd2dc6bafe3deba836105 Mon Sep 17 00:00:00 2001 From: David Moon Date: Thu, 4 Jul 2024 18:00:47 -0400 Subject: [PATCH] fix labeler bug --- src/core/parser/Labeler.re | 8 +++++--- src/core/parser/Labels.re | 7 +++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/core/parser/Labeler.re b/src/core/parser/Labeler.re index 3e0b1829..4cbf1d31 100644 --- a/src/core/parser/Labeler.re +++ b/src/core/parser/Labeler.re @@ -40,9 +40,11 @@ let lexeme = Sedlexing.Latin1.lexeme; let pop = buf => { let mk = (text: string, lbl: Label.t) => { let lbls = - Labels.completions(text) - // avoid dup - |> (Label.is_const(lbl) ? Fun.id : List.cons(lbl)); + switch (Labels.completions(text)) { + | [] => [lbl] + // drop labels like id_lower for exact keyword matches + | [_, ..._] as lbls => Labels.is_const(text) ? lbls : [lbl, ...lbls] + }; Some(Token.Unmolded.mk(~text, Mtrl.Tile(lbls))); }; // I'm guessing buf state is altered by this switch expression? diff --git a/src/core/parser/Labels.re b/src/core/parser/Labels.re index 9f88811d..e52067fa 100644 --- a/src/core/parser/Labels.re +++ b/src/core/parser/Labels.re @@ -10,6 +10,13 @@ let all = |> Label.Set.of_list; let const = Label.Set.(elements(filter(Label.is_const, all))); +let is_const = text => + const + |> List.exists( + fun + | Label.Const(_, t) => String.equal(t, text) + | _ => false, + ); let completions = (prefix: string) => const