Skip to content

Commit

Permalink
fix(merlin): tolerate files without extension (#11128)
Browse files Browse the repository at this point in the history
* fix(merlin): tolerate files without extension

Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>

* chore: add changelog entry

Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>

---------

Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>
  • Loading branch information
anmonteiro authored Nov 18, 2024
1 parent f975cc0 commit 83d2ed4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions doc/changes/11128.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Tolerate files without extension when generating merlin rules.
(#11128, @anmonteiro)
7 changes: 6 additions & 1 deletion src/dune_rules/merlin/merlin.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ open Memo.O

let remove_extension file =
let dir = Path.Build.parent_exn file in
let basename, _ext = String.lsplit2_exn (Path.Build.basename file) ~on:'.' in
let basename =
let basename = Path.Build.basename file in
match String.lsplit2 basename ~on:'.' with
| Some (basename, _ext) -> basename
| None -> basename
in
Path.Build.relative dir basename
;;

Expand Down

0 comments on commit 83d2ed4

Please sign in to comment.