in runtimes/testing/TestFeatures.ts [213:251]
async simulateTyping(uri: string, text: string) {
let remainder = text
while (remainder.length > 0) {
const document = this.documents[uri]!
const contentChange = remainder.substring(0, 1)
remainder = remainder.substring(1)
const newDocument = TextDocument.create(
document.uri,
document.languageId,
document.version + 1,
document.getText() + contentChange
)
this.documents[uri] = newDocument
const endPosition = document.positionAt(document.getText().length)
const range = {
start: endPosition,
end: endPosition,
}
// Force the call to handle after the current task completes
await undefined
this.lsp.onDidChangeTextDocument.args[0]?.[0]({
textDocument: {
uri,
version: document.version,
},
contentChanges: [
{
range,
text: contentChange,
},
],
})
}
return this
}