Skip to content

Commit ec59c6a

Browse files
authored
Account for pipes in completion of single unlabelled argument (#818)
* account for pipes in completion of single unlabelled argument * changelog
1 parent 2b68454 commit ec59c6a

File tree

4 files changed

+28
-1
lines changed

4 files changed

+28
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
- Fix signature help in uncurried mode. https://github.com/rescript-lang/rescript-vscode/pull/809
3636
- Fix various issues in uncurried mode. https://github.com/rescript-lang/rescript-vscode/pull/810
3737
- 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
38+
- 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
3839

3940
## 1.18.0
4041

analysis/src/CompletionFrontEnd.ml

+3-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,9 @@ let findArgCompletables ~(args : arg list) ~endPos ~posBeforeCursor
129129
CArgument
130130
{
131131
functionContextPath = contextPath;
132-
argumentLabel = Unlabelled {argumentPosition = 0};
132+
argumentLabel =
133+
Unlabelled
134+
{argumentPosition = (if isPipedExpr then 1 else 0)};
133135
};
134136
prefix = "";
135137
nested = [];

analysis/tests/src/CompletionExpressions.res

+5
Original file line numberDiff line numberDiff line change
@@ -257,3 +257,8 @@ let fnTakingAsyncCallback = (cb: unit => promise<unit>) => {
257257

258258
// fnTakingAsyncCallback()
259259
// ^com
260+
261+
let arr = ["hello"]
262+
263+
// arr->Belt.Array.map()
264+
// ^com

analysis/tests/src/expected/CompletionExpressions.res.txt

+19
Original file line numberDiff line numberDiff line change
@@ -1094,3 +1094,22 @@ Path fnTakingAsyncCallback
10941094
"insertTextFormat": 2
10951095
}]
10961096

1097+
Complete src/CompletionExpressions.res 262:23
1098+
posCursor:[262:23] posNoWhite:[262:22] Found expr:[262:3->262:24]
1099+
Completable: Cexpression CArgument Value[Belt, Array, map]($1)
1100+
Package opens Pervasives.JsxModules.place holder
1101+
Resolved opens 1 pervasives
1102+
ContextPath CArgument Value[Belt, Array, map]($1)
1103+
ContextPath Value[Belt, Array, map]
1104+
Path Belt.Array.map
1105+
[{
1106+
"label": "v => {}",
1107+
"kind": 12,
1108+
"tags": [],
1109+
"detail": "'a => 'b",
1110+
"documentation": null,
1111+
"sortText": "A",
1112+
"insertText": "${1:v} => {$0}",
1113+
"insertTextFormat": 2
1114+
}]
1115+

0 commit comments

Comments
 (0)