diff --git a/src/vs/editor/contrib/inlineCompletions/browser/provideInlineCompletions.ts b/src/vs/editor/contrib/inlineCompletions/browser/provideInlineCompletions.ts index 8e90d8b431b3a..5373751efa9d9 100644 --- a/src/vs/editor/contrib/inlineCompletions/browser/provideInlineCompletions.ts +++ b/src/vs/editor/contrib/inlineCompletions/browser/provideInlineCompletions.ts @@ -27,6 +27,9 @@ export async function provideInlineCompletions( token: CancellationToken = CancellationToken.None, languageConfigurationService?: ILanguageConfigurationService, ): Promise { + // Important: Don't use position after the await calls, as the model could have been changed in the meantime! + const defaultReplaceRange = getDefaultRange(position, model); + const providers = registry.all(model); const providerResults = await Promise.all(providers.map(async provider => { try { @@ -38,8 +41,6 @@ export async function provideInlineCompletions( return ({ provider, completions: undefined }); })); - const defaultReplaceRange = getDefaultRange(position, model); - const itemsByHash = new Map(); const lists: InlineCompletionList[] = []; for (const result of providerResults) {