Skip to content

Commit

Permalink
fix labeler bug
Browse files Browse the repository at this point in the history
  • Loading branch information
dm0n3y committed Jul 4, 2024
1 parent 99faa14 commit ba41dd7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/core/parser/Labeler.re
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
7 changes: 7 additions & 0 deletions src/core/parser/Labels.re
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ba41dd7

Please sign in to comment.