Skip to content

Account for pipes in completion of single unlabelled argument #818

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

Merged
merged 2 commits into from
Sep 11, 2023
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
- Fix signature help in uncurried mode. https://github.com/rescript-lang/rescript-vscode/pull/809
- Fix various issues in uncurried mode. https://github.com/rescript-lang/rescript-vscode/pull/810
- Fixes a bug in pattern completion where for example `result` wouldn't complete, due to type variables getting lost/not being instantiated. https://github.com/rescript-lang/rescript-vscode/pull/814
- Fix bug where pipes would not be considered in certain cases when completing for single unlabelled function arguments. https://github.com/rescript-lang/rescript-vscode/pull/818

## 1.18.0

Expand Down
4 changes: 3 additions & 1 deletion analysis/src/CompletionFrontEnd.ml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ let findArgCompletables ~(args : arg list) ~endPos ~posBeforeCursor
CArgument
{
functionContextPath = contextPath;
argumentLabel = Unlabelled {argumentPosition = 0};
argumentLabel =
Unlabelled
{argumentPosition = (if isPipedExpr then 1 else 0)};
};
prefix = "";
nested = [];
Expand Down
5 changes: 5 additions & 0 deletions analysis/tests/src/CompletionExpressions.res
Original file line number Diff line number Diff line change
Expand Up @@ -257,3 +257,8 @@ let fnTakingAsyncCallback = (cb: unit => promise<unit>) => {

// fnTakingAsyncCallback()
// ^com

let arr = ["hello"]

// arr->Belt.Array.map()
// ^com
19 changes: 19 additions & 0 deletions analysis/tests/src/expected/CompletionExpressions.res.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1094,3 +1094,22 @@ Path fnTakingAsyncCallback
"insertTextFormat": 2
}]

Complete src/CompletionExpressions.res 262:23
posCursor:[262:23] posNoWhite:[262:22] Found expr:[262:3->262:24]
Completable: Cexpression CArgument Value[Belt, Array, map]($1)
Package opens Pervasives.JsxModules.place holder
Resolved opens 1 pervasives
ContextPath CArgument Value[Belt, Array, map]($1)
ContextPath Value[Belt, Array, map]
Path Belt.Array.map
[{
"label": "v => {}",
"kind": 12,
"tags": [],
"detail": "'a => 'b",
"documentation": null,
"sortText": "A",
"insertText": "${1:v} => {$0}",
"insertTextFormat": 2
}]