Skip to content

Commit 0c33c13

Browse files
authored
Fix completion entry conversion to protocol format (#59410)
1 parent ec7ff81 commit 0c33c13

13 files changed

+881
-279
lines changed

src/server/session.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2469,6 +2469,7 @@ export class Session<TMessage = string> implements EventSender {
24692469
isPackageJsonImport,
24702470
isImportStatementCompletion,
24712471
data,
2472+
commitCharacters,
24722473
} = entry;
24732474
const convertedSpan = replacementSpan ? toProtocolTextSpan(replacementSpan, scriptInfo) : undefined;
24742475
// Use `hasAction || undefined` to avoid serializing `false`.
@@ -2489,6 +2490,7 @@ export class Session<TMessage = string> implements EventSender {
24892490
isPackageJsonImport,
24902491
isImportStatementCompletion,
24912492
data,
2493+
commitCharacters,
24922494
};
24932495
}
24942496
});
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// === Completions ===
2+
=== /src/index.ts ===
3+
// const a: "aa" | "bb" = "";
4+
// ^
5+
// | ----------------------------------------------------------------------
6+
// | aa
7+
// | bb
8+
// | ----------------------------------------------------------------------
9+
10+
[
11+
{
12+
"marker": {
13+
"fileName": "/src/index.ts",
14+
"position": 24,
15+
"name": ""
16+
},
17+
"item": {
18+
"isGlobalCompletion": false,
19+
"isMemberCompletion": false,
20+
"isNewIdentifierLocation": false,
21+
"entries": [
22+
{
23+
"name": "aa",
24+
"kind": "string",
25+
"kindModifiers": "",
26+
"sortText": "11",
27+
"replacementSpan": {
28+
"start": 24,
29+
"length": 0
30+
},
31+
"commitCharacters": [],
32+
"displayParts": [
33+
{
34+
"text": "aa",
35+
"kind": "text"
36+
}
37+
],
38+
"tags": []
39+
},
40+
{
41+
"name": "bb",
42+
"kind": "string",
43+
"kindModifiers": "",
44+
"sortText": "11",
45+
"replacementSpan": {
46+
"start": 24,
47+
"length": 0
48+
},
49+
"commitCharacters": [],
50+
"displayParts": [
51+
{
52+
"text": "bb",
53+
"kind": "text"
54+
}
55+
],
56+
"tags": []
57+
}
58+
],
59+
"defaultCommitCharacters": [
60+
".",
61+
",",
62+
";"
63+
]
64+
}
65+
}
66+
]

tests/baselines/reference/tsserver/completions/works-when-files-are-included-from-two-different-drives-of-windows.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,8 @@ Info seq [hh:mm:ss:mss] response:
764764
"name": "BrowserRouter",
765765
"kind": "warning",
766766
"kindModifiers": "",
767-
"sortText": "18"
767+
"sortText": "18",
768+
"commitCharacters": []
768769
}
769770
],
770771
"defaultCommitCharacters": [

tests/baselines/reference/tsserver/fourslashServer/completionEntryDetailAcrossFiles01.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -713,13 +713,15 @@ Info seq [hh:mm:ss:mss] response:
713713
"name": "exports",
714714
"kind": "warning",
715715
"kindModifiers": "",
716-
"sortText": "18"
716+
"sortText": "18",
717+
"commitCharacters": []
717718
},
718719
{
719720
"name": "p1",
720721
"kind": "warning",
721722
"kindModifiers": "",
722-
"sortText": "18"
723+
"sortText": "18",
724+
"commitCharacters": []
723725
},
724726
{
725727
"name": "escape",

tests/baselines/reference/tsserver/fourslashServer/completionEntryDetailAcrossFiles02.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -719,13 +719,15 @@ Info seq [hh:mm:ss:mss] response:
719719
"name": "exports",
720720
"kind": "warning",
721721
"kindModifiers": "",
722-
"sortText": "18"
722+
"sortText": "18",
723+
"commitCharacters": []
723724
},
724725
{
725726
"name": "p1",
726727
"kind": "warning",
727728
"kindModifiers": "",
728-
"sortText": "18"
729+
"sortText": "18",
730+
"commitCharacters": []
729731
},
730732
{
731733
"name": "escape",
Lines changed: 249 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,249 @@
1+
currentDirectory:: / useCaseSensitiveFileNames: false
2+
Info seq [hh:mm:ss:mss] Provided types map file "/typesMap.json" doesn't exist
3+
//// [/lib.d.ts]
4+
lib.d.ts-Text
5+
6+
//// [/lib.decorators.d.ts]
7+
lib.decorators.d.ts-Text
8+
9+
//// [/lib.decorators.legacy.d.ts]
10+
lib.decorators.legacy.d.ts-Text
11+
12+
//// [/src/index.ts]
13+
const a: "aa" | "bb" = "";
14+
15+
16+
Info seq [hh:mm:ss:mss] request:
17+
{
18+
"seq": 0,
19+
"type": "request",
20+
"arguments": {
21+
"file": "/src/index.ts"
22+
},
23+
"command": "open"
24+
}
25+
Info seq [hh:mm:ss:mss] getConfigFileNameForFile:: File: /src/index.ts ProjectRootPath: undefined:: Result: undefined
26+
Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /dev/null/inferredProject1*
27+
Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /lib.d.ts 500 undefined WatchType: Closed Script info
28+
Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /lib.decorators.d.ts 500 undefined WatchType: Closed Script info
29+
Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /lib.decorators.legacy.d.ts 500 undefined WatchType: Closed Script info
30+
Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /dev/null/inferredProject1* projectStateVersion: 1 projectProgramVersion: 0 structureChanged: true structureIsReused:: Not Elapsed:: *ms
31+
Info seq [hh:mm:ss:mss] Project '/dev/null/inferredProject1*' (Inferred)
32+
Info seq [hh:mm:ss:mss] Files (4)
33+
/lib.d.ts Text-1 lib.d.ts-Text
34+
/lib.decorators.d.ts Text-1 lib.decorators.d.ts-Text
35+
/lib.decorators.legacy.d.ts Text-1 lib.decorators.legacy.d.ts-Text
36+
/src/index.ts SVC-1-0 "const a: \"aa\" | \"bb\" = \"\";"
37+
38+
39+
../lib.d.ts
40+
Default library for target 'es5'
41+
../lib.decorators.d.ts
42+
Library referenced via 'decorators' from file '../lib.d.ts'
43+
../lib.decorators.legacy.d.ts
44+
Library referenced via 'decorators.legacy' from file '../lib.d.ts'
45+
index.ts
46+
Root file specified for compilation
47+
48+
Info seq [hh:mm:ss:mss] -----------------------------------------------
49+
Info seq [hh:mm:ss:mss] Project '/dev/null/inferredProject1*' (Inferred)
50+
Info seq [hh:mm:ss:mss] Files (4)
51+
52+
Info seq [hh:mm:ss:mss] -----------------------------------------------
53+
Info seq [hh:mm:ss:mss] Open files:
54+
Info seq [hh:mm:ss:mss] FileName: /src/index.ts ProjectRootPath: undefined
55+
Info seq [hh:mm:ss:mss] Projects: /dev/null/inferredProject1*
56+
Info seq [hh:mm:ss:mss] response:
57+
{
58+
"seq": 0,
59+
"type": "response",
60+
"command": "open",
61+
"request_seq": 0,
62+
"success": true,
63+
"performanceData": {
64+
"updateGraphDurationMs": *
65+
}
66+
}
67+
After Request
68+
watchedFiles::
69+
/lib.d.ts: *new*
70+
{"pollingInterval":500}
71+
/lib.decorators.d.ts: *new*
72+
{"pollingInterval":500}
73+
/lib.decorators.legacy.d.ts: *new*
74+
{"pollingInterval":500}
75+
76+
Projects::
77+
/dev/null/inferredProject1* (Inferred) *new*
78+
projectStateVersion: 1
79+
projectProgramVersion: 1
80+
81+
ScriptInfos::
82+
/lib.d.ts *new*
83+
version: Text-1
84+
containingProjects: 1
85+
/dev/null/inferredProject1*
86+
/lib.decorators.d.ts *new*
87+
version: Text-1
88+
containingProjects: 1
89+
/dev/null/inferredProject1*
90+
/lib.decorators.legacy.d.ts *new*
91+
version: Text-1
92+
containingProjects: 1
93+
/dev/null/inferredProject1*
94+
/src/index.ts (Open) *new*
95+
version: SVC-1-0
96+
containingProjects: 1
97+
/dev/null/inferredProject1* *default*
98+
99+
Info seq [hh:mm:ss:mss] request:
100+
{
101+
"seq": 1,
102+
"type": "request",
103+
"arguments": {
104+
"file": "/src/index.ts",
105+
"line": 1,
106+
"offset": 25
107+
},
108+
"command": "completionInfo"
109+
}
110+
Info seq [hh:mm:ss:mss] response:
111+
{
112+
"seq": 0,
113+
"type": "response",
114+
"command": "completionInfo",
115+
"request_seq": 1,
116+
"success": true,
117+
"body": {
118+
"isGlobalCompletion": false,
119+
"isMemberCompletion": false,
120+
"isNewIdentifierLocation": false,
121+
"optionalReplacementSpan": {
122+
"start": {
123+
"line": 1,
124+
"offset": 25
125+
},
126+
"end": {
127+
"line": 1,
128+
"offset": 25
129+
}
130+
},
131+
"entries": [
132+
{
133+
"name": "aa",
134+
"kind": "string",
135+
"kindModifiers": "",
136+
"sortText": "11",
137+
"replacementSpan": {
138+
"start": {
139+
"line": 1,
140+
"offset": 25
141+
},
142+
"end": {
143+
"line": 1,
144+
"offset": 25
145+
}
146+
},
147+
"commitCharacters": []
148+
},
149+
{
150+
"name": "bb",
151+
"kind": "string",
152+
"kindModifiers": "",
153+
"sortText": "11",
154+
"replacementSpan": {
155+
"start": {
156+
"line": 1,
157+
"offset": 25
158+
},
159+
"end": {
160+
"line": 1,
161+
"offset": 25
162+
}
163+
},
164+
"commitCharacters": []
165+
}
166+
],
167+
"defaultCommitCharacters": [
168+
".",
169+
",",
170+
";"
171+
]
172+
}
173+
}
174+
Info seq [hh:mm:ss:mss] request:
175+
{
176+
"seq": 2,
177+
"type": "request",
178+
"arguments": {
179+
"file": "/src/index.ts",
180+
"line": 1,
181+
"offset": 25,
182+
"entryNames": [
183+
{
184+
"name": "aa"
185+
}
186+
]
187+
},
188+
"command": "completionEntryDetails-full"
189+
}
190+
Info seq [hh:mm:ss:mss] response:
191+
{
192+
"seq": 0,
193+
"type": "response",
194+
"command": "completionEntryDetails-full",
195+
"request_seq": 2,
196+
"success": true,
197+
"body": [
198+
{
199+
"name": "aa",
200+
"kindModifiers": "",
201+
"kind": "string",
202+
"displayParts": [
203+
{
204+
"text": "aa",
205+
"kind": "text"
206+
}
207+
],
208+
"tags": []
209+
}
210+
]
211+
}
212+
Info seq [hh:mm:ss:mss] request:
213+
{
214+
"seq": 3,
215+
"type": "request",
216+
"arguments": {
217+
"file": "/src/index.ts",
218+
"line": 1,
219+
"offset": 25,
220+
"entryNames": [
221+
{
222+
"name": "bb"
223+
}
224+
]
225+
},
226+
"command": "completionEntryDetails-full"
227+
}
228+
Info seq [hh:mm:ss:mss] response:
229+
{
230+
"seq": 0,
231+
"type": "response",
232+
"command": "completionEntryDetails-full",
233+
"request_seq": 3,
234+
"success": true,
235+
"body": [
236+
{
237+
"name": "bb",
238+
"kindModifiers": "",
239+
"kind": "string",
240+
"displayParts": [
241+
{
242+
"text": "bb",
243+
"kind": "text"
244+
}
245+
],
246+
"tags": []
247+
}
248+
]
249+
}

tests/baselines/reference/tsserver/fourslashServer/jsdocParamTagSpecialKeywords.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,13 +296,15 @@ Info seq [hh:mm:ss:mss] response:
296296
"name": "test",
297297
"kind": "warning",
298298
"kindModifiers": "",
299-
"sortText": "18"
299+
"sortText": "18",
300+
"commitCharacters": []
300301
},
301302
{
302303
"name": "type",
303304
"kind": "warning",
304305
"kindModifiers": "",
305-
"sortText": "18"
306+
"sortText": "18",
307+
"commitCharacters": []
306308
},
307309
{
308310
"name": "substr",

0 commit comments

Comments
 (0)