canceled ollama requests on token canceled

This commit is contained in:
Leyla Becker 2025-07-19 19:50:34 -05:00
parent 02e65c5700
commit f93d24dc39

View file

@ -87,7 +87,7 @@ const tokenProvider = async (
document: vscode.TextDocument,
position: vscode.Position,
_context: vscode.InlineCompletionContext,
_token: vscode.CancellationToken,
token: vscode.CancellationToken,
) => {
const prefix = document.getText(new vscode.Range(0, 0, position.line, position.character));
@ -114,6 +114,10 @@ const tokenProvider = async (
},
});
token.onCancellationRequested(() => {
response.abort();
});
const resultBuffer: string[] = await new Promise(async (resolve, reject) => {
const buffer: string[] = [];
const timeout = setTimeout(() => {