Skip to content

Commit 6539780

Browse files
committed
fix(completion): don't complete anything in parameters
Fixes #152
1 parent de8b282 commit 6539780

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

server/src/completion/CompletionContext.ts

+7
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,13 @@ export class CompletionContext {
160160
if (parent.type.endsWith("_function")) {
161161
this.isExpression = false
162162
this.isStatement = false
163+
this.inParameter = true
164+
}
165+
166+
if (parent.type === "ERROR" && parent.parent?.type.endsWith("_function")) {
167+
this.isExpression = false
168+
this.isStatement = false
169+
this.inParameter = true
163170
}
164171

165172
if (parent.type === "trait_list") {

server/src/e2e/suite/testcases/completion/contracts.test

+34
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,37 @@ contract Foo {
5050
14 try-catch
5151
14 until
5252
14 while
53+
54+
========================================================================
55+
Completion inside `receive()` parameters
56+
========================================================================
57+
contract Foo {
58+
receive(<caret>) {}
59+
}
60+
------------------------------------------------------------------------
61+
0 contract
62+
0 Foo
63+
0 receive
64+
65+
========================================================================
66+
Completion inside `external()` parameters
67+
========================================================================
68+
contract Foo {
69+
external(<caret>) {}
70+
}
71+
------------------------------------------------------------------------
72+
0 contract
73+
0 external
74+
0 Foo
75+
76+
========================================================================
77+
Completion inside `fun()` parameters
78+
========================================================================
79+
contract Foo {
80+
fun foo(<caret>) {}
81+
}
82+
------------------------------------------------------------------------
83+
0 contract
84+
0 Foo
85+
0 foo
86+
0 fun

0 commit comments

Comments
 (0)