Skip to content

Commit

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

Signed-off-by: Antonio Nuno Monteiro <[email protected]>

* chore: add changelog entry

Signed-off-by: Antonio Nuno Monteiro <[email protected]>

---------

Signed-off-by: Antonio Nuno Monteiro <[email protected]>
Signed-off-by: Chris Armstrong <[email protected]>
  • Loading branch information
anmonteiro authored and chris-armstrong committed Jan 29, 2025
1 parent 7a6597f commit 1f7fe79
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 1f7fe79

Please sign in to comment.