@@ -25,7 +25,7 @@ import { Selection } from '../../../../common/core/selection.js';
2525import { TextReplacement , TextEdit } from '../../../../common/core/edits/textEdit.js' ;
2626import { TextLength } from '../../../../common/core/text/textLength.js' ;
2727import { ScrollType } from '../../../../common/editorCommon.js' ;
28- import { InlineCompletionEndOfLifeReasonKind , InlineCompletion , InlineCompletionTriggerKind , PartialAcceptTriggerKind , InlineCompletionsProvider , InlineCompletionCommand } from '../../../../common/languages.js' ;
28+ import { InlineCompletionEndOfLifeReasonKind , InlineCompletion , InlineCompletionTriggerKind , PartialAcceptTriggerKind , InlineCompletionsProvider , InlineCompletionCommand , InlineCompletions } from '../../../../common/languages.js' ;
2929import { ILanguageConfigurationService } from '../../../../common/languages/languageConfigurationRegistry.js' ;
3030import { EndOfLinePreference , IModelDeltaDecoration , ITextModel } from '../../../../common/model.js' ;
3131import { TextModelText } from '../../../../common/model/textModelText.js' ;
@@ -189,6 +189,7 @@ export class InlineCompletionsModel extends Disposable {
189189 }
190190 } ) ) ;
191191
192+ // TODO: should use getAvailableProviders and update on _suppressedInlineCompletionGroupIds change
192193 const inlineCompletionProviders = observableFromEvent ( this . _languageFeaturesService . inlineCompletionsProvider . onDidChange , ( ) => this . _languageFeaturesService . inlineCompletionsProvider . all ( textModel ) ) ;
193194 mapObservableArrayCached ( this , inlineCompletionProviders , ( provider , store ) => {
194195 if ( ! provider . onDidChangeInlineCompletions ) {
@@ -423,13 +424,34 @@ export class InlineCompletionsModel extends Disposable {
423424
424425 const providers = changeSummary . provider
425426 ? { providers : [ changeSummary . provider ] , label : 'single:' + changeSummary . provider . providerId ?. toString ( ) }
426- : { providers : this . _languageFeaturesService . inlineCompletionsProvider . all ( this . textModel ) , label : undefined } ;
427- const suppressedProviderGroupIds = this . _suppressedInlineCompletionGroupIds . get ( ) ;
428- const availableProviders = providers . providers . filter ( provider => ! ( provider . groupId && suppressedProviderGroupIds . has ( provider . groupId ) ) ) ;
427+ : { providers : this . _languageFeaturesService . inlineCompletionsProvider . all ( this . textModel ) , label : undefined } ; // TODO: should use inlineCompletionProviders
428+ const availableProviders = this . getAvailableProviders ( providers . providers ) ;
429429
430430 return this . _source . fetch ( availableProviders , providers . label , context , itemToPreserve ?. identity , changeSummary . shouldDebounce , userJumpedToActiveCompletion , requestInfo ) ;
431431 } ) ;
432432
433+ // TODO: This is not an ideal implementation of excludesGroupIds, however as this is currently still behind proposed API
434+ // and due to the time constraints, we are using a simplified approach
435+ private getAvailableProviders ( providers : InlineCompletionsProvider < InlineCompletions < InlineCompletion > > [ ] ) : InlineCompletionsProvider [ ] {
436+ const suppressedProviderGroupIds = this . _suppressedInlineCompletionGroupIds . get ( ) ;
437+ const unsuppressedProviders = providers . filter ( provider => ! ( provider . groupId && suppressedProviderGroupIds . has ( provider . groupId ) ) ) ;
438+
439+ const excludedGroupIds = new Set < string > ( ) ;
440+ for ( const provider of unsuppressedProviders ) {
441+ provider . excludesGroupIds ?. forEach ( p => excludedGroupIds . add ( p ) ) ;
442+ }
443+
444+ const availableProviders : InlineCompletionsProvider < InlineCompletions < InlineCompletion > > [ ] = [ ] ;
445+ for ( const provider of unsuppressedProviders ) {
446+ if ( provider . groupId && excludedGroupIds . has ( provider . groupId ) ) {
447+ continue ;
448+ }
449+ availableProviders . push ( provider ) ;
450+ }
451+
452+ return availableProviders ;
453+ }
454+
433455 public async trigger ( tx ?: ITransaction , options ?: { onlyFetchInlineEdits ?: boolean ; noDelay ?: boolean } ) : Promise < void > {
434456 subtransaction ( tx , tx => {
435457 if ( options ?. onlyFetchInlineEdits ) {
0 commit comments