Skip to content

Commit d4834d9

Browse files
authored
add extra leading space for description of completion item for editors like Neovim (#36)
1 parent dda4587 commit d4834d9

File tree

7 files changed

+91
-89
lines changed

7 files changed

+91
-89
lines changed

server/src/completion/ReferenceCompletionProcessor.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ export class ReferenceCompletionProcessor implements ScopeProcessor {
175175
kind: CompletionItemKind.Property,
176176
labelDetails: {
177177
detail: details,
178-
description: `of ${owner}`,
178+
description: ` of ${owner}`,
179179
},
180180
insertText: thisPrefix + name + suffix,
181181
insertTextFormat: InsertTextFormat.Snippet,
@@ -194,12 +194,13 @@ export class ReferenceCompletionProcessor implements ScopeProcessor {
194194
parent.type === "catch_clause"
195195
) {
196196
const type = TypeInferer.inferType(node)
197+
const typeName = type?.qualifiedName() ?? "unknown"
197198

198199
this.addItem({
199200
label: name,
200201
kind: CompletionItemKind.Variable,
201202
labelDetails: {
202-
description: type?.qualifiedName() ?? "unknown",
203+
description: ` ${typeName}`,
203204
},
204205
insertText: name,
205206
insertTextFormat: InsertTextFormat.Snippet,
@@ -214,12 +215,13 @@ export class ReferenceCompletionProcessor implements ScopeProcessor {
214215
if (!parent) return true
215216

216217
const type = TypeInferer.inferType(node)
218+
const typeName = type?.qualifiedName() ?? "unknown"
217219

218220
this.addItem({
219221
label: name,
220222
kind: CompletionItemKind.Variable,
221223
labelDetails: {
222-
description: type?.qualifiedName() ?? "unknown",
224+
description: ` ${typeName}`,
223225
},
224226
insertText: name,
225227
insertTextFormat: InsertTextFormat.Snippet,

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

+27-27
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ fun test(msg: Transfer) {
1313
msg.<caret>
1414
}
1515
------------------------------------------------------------------------
16-
9 amount: Int of Transfer
17-
9 to: Address of Transfer
16+
9 amount: Int of Transfer
17+
9 to: Address of Transfer
1818

1919
========================================================================
2020
Struct fields completion
@@ -31,9 +31,9 @@ fun test(p: Point) {
3131
p.<caret>
3232
}
3333
------------------------------------------------------------------------
34-
9 x: Int of Point
35-
9 y: Int of Point
36-
9 z: Int? of Point
34+
9 x: Int of Point
35+
9 y: Int of Point
36+
9 z: Int? of Point
3737

3838
========================================================================
3939
Contract fields completion
@@ -55,8 +55,8 @@ fun test(c: Counter) {
5555
c.<caret>
5656
}
5757
------------------------------------------------------------------------
58-
9 owner: Address of Counter
59-
9 val: Int of Counter
58+
9 owner: Address of Counter
59+
9 val: Int of Counter
6060

6161
========================================================================
6262
Map fields completion
@@ -73,8 +73,8 @@ fun test(s: Storage) {
7373
s.<caret>
7474
}
7575
------------------------------------------------------------------------
76-
9 allowances: map<Address, Int> of Storage
77-
9 balances: map<Address, Int> of Storage
76+
9 allowances: map<Address, Int> of Storage
77+
9 balances: map<Address, Int> of Storage
7878

7979
========================================================================
8080
Optional fields completion
@@ -92,9 +92,9 @@ fun test(u: User?) {
9292
u.<caret>
9393
}
9494
------------------------------------------------------------------------
95-
9 address: Address? of User
96-
9 age: Int? of User
97-
9 name: of User
95+
9 address: Address? of User
96+
9 age: Int? of User
97+
9 name: of User
9898

9999
========================================================================
100100
Nested fields completion
@@ -114,7 +114,7 @@ fun test(o: Outer) {
114114
o.inner.<caret>
115115
}
116116
------------------------------------------------------------------------
117-
9 value: Int of Inner
117+
9 value: Int of Inner
118118

119119
========================================================================
120120
Message with TLB fields completion
@@ -134,11 +134,11 @@ fun test(msg: TokenTransfer) {
134134
msg.<caret>
135135
}
136136
------------------------------------------------------------------------
137-
9 amount: Int of TokenTransfer
138-
9 from: Address of TokenTransfer
139-
9 queryId: Int of TokenTransfer
140-
9 responseDestination: Address? of TokenTransfer
141-
9 to: Address of TokenTransfer
137+
9 amount: Int of TokenTransfer
138+
9 from: Address of TokenTransfer
139+
9 queryId: Int of TokenTransfer
140+
9 responseDestination: Address? of TokenTransfer
141+
9 to: Address of TokenTransfer
142142

143143
========================================================================
144144
Field of bounced<struct>
@@ -159,9 +159,9 @@ contract Foo {
159159
}
160160
}
161161
------------------------------------------------------------------------
162-
9 address: Address? of User
163-
9 age: Int? of User
164-
9 name: String of User
162+
9 address: Address? of User
163+
9 age: Int? of User
164+
9 name: String of User
165165

166166
========================================================================
167167
Field of option struct without unwrapping
@@ -180,9 +180,9 @@ fun foo(f: User?) {
180180
f.<caret>
181181
}
182182
------------------------------------------------------------------------
183-
9 address: Address? of User
184-
9 age: Int? of User
185-
9 name: String of User
183+
9 address: Address? of User
184+
9 age: Int? of User
185+
9 name: String of User
186186

187187
========================================================================
188188
Field of option struct with unwrapping
@@ -201,6 +201,6 @@ fun foo(f: User?) {
201201
f!!.<caret>
202202
}
203203
------------------------------------------------------------------------
204-
9 address: Address? of User
205-
9 age: Int? of User
206-
9 name: String of User
204+
9 address: Address? of User
205+
9 age: Int? of User
206+
9 name: String of User

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ fun test() {
4646
let result = <caret>
4747
}
4848
------------------------------------------------------------------------
49-
5 result unknown
49+
5 result unknown
5050
13 false
5151
13 null
5252
13 true
@@ -87,7 +87,7 @@ fun test() {
8787
let x = add(<caret>)
8888
}
8989
------------------------------------------------------------------------
90-
5 x Int
90+
5 x Int
9191
13 false
9292
13 null
9393
13 true

server/src/e2e/suite/testcases/completion/struct-init.test

+9-9
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ fun test() {
1111
Foo{ <caret> };
1212
}
1313
------------------------------------------------------------------------
14-
9 age : Int of Foo
14+
9 age : Int of Foo
1515

1616
========================================================================
1717
First field in struct init with variable
@@ -28,8 +28,8 @@ fun test() {
2828
Foo{ <caret> };
2929
}
3030
------------------------------------------------------------------------
31-
5 age Int
32-
9 age : Int of Foo
31+
5 age Int
32+
9 age : Int of Foo
3333

3434
========================================================================
3535
First field in struct init with parameter
@@ -44,8 +44,8 @@ fun test(age: Int, some: Int) {
4444
Foo{ <caret> };
4545
}
4646
------------------------------------------------------------------------
47-
5 age Int
48-
9 age : Int of Foo
47+
5 age Int
48+
9 age : Int of Foo
4949

5050
========================================================================
5151
Second field in struct init
@@ -61,7 +61,7 @@ fun test() {
6161
Foo{ age: 10, <caret> };
6262
}
6363
------------------------------------------------------------------------
64-
9 value : Int of Foo
64+
9 value : Int of Foo
6565

6666
========================================================================
6767
Second field in struct init 2
@@ -77,8 +77,8 @@ fun test() {
7777
Foo{ <caret> value: 10 };
7878
}
7979
------------------------------------------------------------------------
80-
9 age: Int of Foo
81-
9 value: Int of Foo
80+
9 age: Int of Foo
81+
9 value: Int of Foo
8282
13 false
8383
13 null
8484
13 true
@@ -98,7 +98,7 @@ fun test() {
9898
Foo{ age: 10, <caret> };
9999
}
100100
------------------------------------------------------------------------
101-
9 value : Int of Foo
101+
9 value : Int of Foo
102102

103103
========================================================================
104104
Completion in field value

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ trait Child with Parent {
161161
}
162162
}
163163
------------------------------------------------------------------------
164-
9 self.field: Int of Child
164+
9 self.field: Int of Child
165165
13 false
166166
13 null
167167
13 return <expr>;

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

+14-14
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ fun test() {
1212
value = <caret>
1313
}
1414
------------------------------------------------------------------------
15-
5 value Bool
15+
5 value Bool
1616
13 false
1717
13 true
1818
2 bar(): Bool
@@ -62,12 +62,12 @@ fun test() {
6262
value = <caret>
6363
}
6464
------------------------------------------------------------------------
65-
5 someValue Int
66-
5 value Int?
65+
5 someValue Int
66+
5 value Int?
6767
13 null
6868
2 bar(): Int
6969
2 foo(): Int
70-
5 someBool Bool
70+
5 someBool Bool
7171
13 false
7272
13 true
7373
2 test()
@@ -89,12 +89,12 @@ fun test() {
8989
let value: Int? = <caret>;
9090
}
9191
------------------------------------------------------------------------
92-
5 someValue Int
93-
5 value Int?
92+
5 someValue Int
93+
5 value Int?
9494
13 null
9595
2 bar(): Int
9696
2 foo(): Int
97-
5 someBool Bool
97+
5 someBool Bool
9898
13 false
9999
13 true
100100
2 test()
@@ -116,9 +116,9 @@ fun test() {
116116
let value = <caret>;
117117
}
118118
------------------------------------------------------------------------
119-
5 someBool Bool
120-
5 someValue Int
121-
5 value unknown
119+
5 someBool Bool
120+
5 someValue Int
121+
5 value unknown
122122
13 false
123123
13 null
124124
13 true
@@ -146,13 +146,13 @@ fun test() {
146146
let value: MyStruct = <caret>;
147147
}
148148
------------------------------------------------------------------------
149-
5 someStruct MyStruct
150-
5 value MyStruct
149+
5 someStruct MyStruct
150+
5 value MyStruct
151151
2 bar(): MyStruct
152152
2 foo(): MyStruct
153153
21 MyStruct{}
154-
5 someBool Bool
155-
5 someValue Int
154+
5 someBool Bool
155+
5 someValue Int
156156
13 false
157157
13 null
158158
13 true

0 commit comments

Comments
 (0)