Skip to content

Commit 7ee1590

Browse files
Request completion entry details from all auto-import entries. (#95)
1 parent 877d69f commit 7ee1590

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

src/utils/exerciseServer.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,13 +288,16 @@ async function exerciseServerWorker(testDir: string, tsserverPath: string, repla
288288
}
289289
}, isAt ? 0.5 : 0.00005);
290290

291+
// auto-imports are too slow to test everywhere
292+
const requestWithAutoImports = prng.random() < 0.02;
293+
291294
const invokedResponse = await message({
292295
"command": "completionInfo",
293296
"arguments": {
294297
"file": openFileAbsolutePath,
295298
"line": line,
296299
"offset": column,
297-
"includeExternalModuleExports": prng.random() < 0.01, // auto-imports are too slow to test everywhere
300+
"includeExternalModuleExports": requestWithAutoImports,
298301
"triggerKind": 1,
299302
}
300303
}, isAt ? 0.5 : 0.001);
@@ -311,6 +314,30 @@ async function exerciseServerWorker(testDir: string, tsserverPath: string, repla
311314
],
312315
}
313316
});
317+
318+
// Auto-import completions frequently cause issues with completion entry details.
319+
if (requestWithAutoImports) {
320+
const completionEntries = invokedResponse.body.entries;
321+
for (let entry of completionEntries) {
322+
if (entry.hasAction && entry.source !== undefined && "data" in entry) {
323+
const { name, source, data } = entry;
324+
325+
// 'completionEntryDetails' can take multiple entries; however, it's not useful for diagnostics
326+
// to report that "this command failed when asking for details on any of these 100 completions."
327+
await message({
328+
"command": "completionEntryDetails",
329+
"arguments": {
330+
"file": openFileAbsolutePath,
331+
"line": line,
332+
"offset": column,
333+
"entryNames": [
334+
{ name, source, data },
335+
],
336+
}
337+
})
338+
}
339+
}
340+
}
314341
}
315342

316343
const triggerCharIndex = triggerChars.indexOf(curr);

0 commit comments

Comments
 (0)