@@ -794,4 +794,46 @@ describe('CompletionRouter', () => {
794794 } ) ;
795795 } ) ;
796796 } ) ;
797+
798+ describe ( 'isIncomplete handling' , ( ) => {
799+ test ( 'should set isIncomplete to true when results exceed maxCompletions' , ( ) => {
800+ const mockProvider = {
801+ getCompletions : vi
802+ . fn ( )
803+ . mockReturnValue ( Array . from ( { length : 150 } , ( _ , i ) => ( { label : `Item${ i } ` , kind : 1 } ) ) ) ,
804+ } ;
805+
806+ completionRouter [ 'completionProviderMap' ] . set ( 'TopLevelSection' , mockProvider ) ;
807+ completionRouter [ 'completionSettings' ] = { ...completionRouter [ 'completionSettings' ] , maxCompletions : 100 } ;
808+
809+ const mockContext = createTopLevelContext ( 'Unknown' , { text : '' } ) ;
810+ mockComponents . contextManager . getContext . returns ( mockContext ) ;
811+
812+ const result = completionRouter . getCompletions ( mockParams ) as CompletionList | undefined ;
813+
814+ expect ( result ) . toBeDefined ( ) ;
815+ expect ( result ! . isIncomplete ) . toBe ( true ) ;
816+ expect ( result ! . items . length ) . toBe ( 100 ) ;
817+ } ) ;
818+
819+ test ( 'should set isIncomplete to false when results are within maxCompletions' , ( ) => {
820+ const mockProvider = {
821+ getCompletions : vi
822+ . fn ( )
823+ . mockReturnValue ( Array . from ( { length : 50 } , ( _ , i ) => ( { label : `Item${ i } ` , kind : 1 } ) ) ) ,
824+ } ;
825+
826+ completionRouter [ 'completionProviderMap' ] . set ( 'TopLevelSection' , mockProvider ) ;
827+ completionRouter [ 'completionSettings' ] = { ...completionRouter [ 'completionSettings' ] , maxCompletions : 100 } ;
828+
829+ const mockContext = createTopLevelContext ( 'Unknown' , { text : '' } ) ;
830+ mockComponents . contextManager . getContext . returns ( mockContext ) ;
831+
832+ const result = completionRouter . getCompletions ( mockParams ) as CompletionList | undefined ;
833+
834+ expect ( result ) . toBeDefined ( ) ;
835+ expect ( result ! . isIncomplete ) . toBe ( false ) ;
836+ expect ( result ! . items . length ) . toBe ( 50 ) ;
837+ } ) ;
838+ } ) ;
797839} ) ;
0 commit comments