Skip to content

Request completion entry details from auto-import entries. #95

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion src/utils/exerciseServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,13 +288,16 @@ async function exerciseServerWorker(testDir: string, tsserverPath: string, repla
}
}, isAt ? 0.5 : 0.00005);

// auto-imports are too slow to test everywhere
const requestWithAutoImports = prng.random() < 0.02;

const invokedResponse = await message({
"command": "completionInfo",
"arguments": {
"file": openFileAbsolutePath,
"line": line,
"offset": column,
"includeExternalModuleExports": prng.random() < 0.01, // auto-imports are too slow to test everywhere
"includeExternalModuleExports": requestWithAutoImports,
"triggerKind": 1,
}
}, isAt ? 0.5 : 0.001);
Expand All @@ -311,6 +314,30 @@ async function exerciseServerWorker(testDir: string, tsserverPath: string, repla
],
}
});

// Auto-import completions frequently cause issues with completion entry details.
if (requestWithAutoImports) {
const completionEntries = invokedResponse.body.entries;
for (let entry of completionEntries) {
if (entry.hasAction && entry.source !== undefined && "data" in entry) {
const { name, source, data } = entry;

// 'completionEntryDetails' can take multiple entries; however, it's not useful for diagnostics
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious to hear if others think this is bad - this is pretty likely to be slower, but I like to look at the last command and know exactly what went wrong.

I could make requests on 5 at a time in the future.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK nobody uses the multiple-details-at-a-time command. IIRC it’s not optimized whatsoever; it just loops at the super top level and doesn’t cache anything.

// to report that "this command failed when asking for details on any of these 100 completions."
await message({
"command": "completionEntryDetails",
"arguments": {
"file": openFileAbsolutePath,
"line": line,
"offset": column,
"entryNames": [
{ name, source, data },
],
}
})
}
}
}
}

const triggerCharIndex = triggerChars.indexOf(curr);
Expand Down