Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display message instead of empty list #1695

Merged
merged 2 commits into from
Dec 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading