Skip to content

Commit

Permalink
Display message instead of empty list (#1695)
Browse files Browse the repository at this point in the history
* display message instead of empty list

* add changelog
  • Loading branch information
PizieDust authored Dec 25, 2024
1 parent edcf20f commit 55f064e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

# Unreleased

- Construct: display a message when construct list is empty. (#1695)

## 1.26.0

- Add `ocaml.navigate-typed-holes` to navigate between typed holes. (#1666)
Expand Down
39 changes: 21 additions & 18 deletions src/extension_commands.ml
Original file line number Diff line number Diff line change
Expand Up @@ -596,24 +596,27 @@ module Construct = struct
let rec process_construct position text_editor client instance =
let open Promise.Syntax in
let* res = get_construct_results position text_editor client in
let* selected_result = display_results res in
match selected_result with
| Some (value, range) ->
let* value_inserted = insert_to_document text_editor range value in
(match Settings.(get server_constructRecursiveCalls_setting) with
| Some true | None ->
(match value_inserted with
| true ->
let* new_range =
Holes_commands.closest_hole (Range.start range) text_editor client `Next
in
(match new_range with
| Some range ->
process_construct (Range.end_ range) text_editor client instance
| None -> Promise.return ())
| false -> Promise.return ())
| Some false -> Promise.return ())
| None -> Promise.return ()
match res.result with
| [] -> show_message `Info "No values to construct this typed hole." |> Promise.return
| _result_list ->
let* selected_result = display_results res in
(match selected_result with
| Some (value, range) ->
let* value_inserted = insert_to_document text_editor range value in
(match Settings.(get server_constructRecursiveCalls_setting) with
| Some true | None ->
(match value_inserted with
| true ->
let* new_range =
Holes_commands.closest_hole (Range.start range) text_editor client `Next
in
(match new_range with
| Some range ->
process_construct (Range.end_ range) text_editor client instance
| None -> Promise.return ())
| false -> Promise.return ())
| Some false -> Promise.return ())
| None -> Promise.return ())
;;

let _construct =
Expand Down

0 comments on commit 55f064e

Please sign in to comment.