Skip to content
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
22 changes: 21 additions & 1 deletion src/utils/exerciseLspServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,10 +322,18 @@ async function exerciseLspServerWorker(testDir: string, lspServerPath: string, r

const inlayHintsPromise = request("textDocument/inlayHint", {
textDocument: { uri: openFileUri },
// TODO - this is still a hack.
// Could just move it to the end after we've iterated through the file.
Copy link
Member

Choose a reason for hiding this comment

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

Why is this a hack?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because clients and servers are supposed to agree not to index past any given line's length. Instead of counting the lines of the file up front and calculating a line map, I just used the character position.

range: { start: { line: 0, character: 0 }, end: { line: 0, character: openFileContents.length } },
});

await Promise.all([diagnosticsPromise, codeLensesPromise, inlayHintsPromise]);
const [_diags, codeLenses, _inlayHints] = await Promise.all([diagnosticsPromise, codeLensesPromise, inlayHintsPromise]);

if (codeLenses) {
await Promise.all(codeLenses.map(async (lens) => {
await request("codeLens/resolve", lens);
}));
}

for (let i = 0; i < openFileContents.length; i++) {
const curr = openFileContents[i];
Expand Down Expand Up @@ -429,6 +437,18 @@ async function exerciseLspServerWorker(testDir: string, lspServerPath: string, r

prev = curr;
}

// We do these at the end since we'd prefer to catch other crashes like completions first.
await request("textDocument/formatting", {
textDocument: { uri: openFileUri },
options: {
tabSize: prng.intBetween(0, 4),
insertSpaces: prng.random() < 0.5,
trimTrailingWhitespace: prng.random() < 0.90,
trimFinalNewlines: prng.random() < 0.90,
insertFinalNewline: prng.random() < 0.90,
},
});
}

console.error("\nShutting down server");
Expand Down