@@ -128,7 +128,6 @@ protected string GetOneHistorySuggestion(string text)
128128 /// <param name="count">Maximum number of results to return.</param>
129129 protected List < SuggestionEntry > GetHistorySuggestions ( string input , int count )
130130 {
131- const string source = "History" ;
132131 List < SuggestionEntry > results = null ;
133132 int remainingCount = count ;
134133
@@ -164,15 +163,15 @@ protected List<SuggestionEntry> GetHistorySuggestions(string input, int count)
164163 _cacheHistorySet . Add ( line ) ;
165164 if ( matchIndex == 0 )
166165 {
167- results . Add ( new SuggestionEntry ( source , Guid . Empty , line , matchIndex ) ) ;
166+ results . Add ( new SuggestionEntry ( line , matchIndex ) ) ;
168167 if ( -- remainingCount == 0 )
169168 {
170169 break ;
171170 }
172171 }
173172 else if ( _cacheHistoryList . Count < remainingCount )
174173 {
175- _cacheHistoryList . Add ( new SuggestionEntry ( source , Guid . Empty , line , matchIndex ) ) ;
174+ _cacheHistoryList . Add ( new SuggestionEntry ( line , matchIndex ) ) ;
176175 }
177176 }
178177
@@ -440,11 +439,19 @@ private void AggregateSuggestions()
440439 break ;
441440 }
442441
443- for ( int i = 0 ; i < _cacheList2 [ index ] ; i ++ )
442+ int num = _cacheList2 [ index ] ;
443+ for ( int i = 0 ; i < num ; i ++ )
444444 {
445445 string sugText = item . Suggestions [ i ] . SuggestionText ?? string . Empty ;
446446 int matchIndex = sugText . IndexOf ( _inputText , comparison ) ;
447- _listItems . Add ( new SuggestionEntry ( item . Name , item . Id , sugText , matchIndex ) ) ;
447+ _listItems . Add ( new SuggestionEntry ( item . Name , item . Id , item . Session , sugText , matchIndex ) ) ;
448+ }
449+
450+ if ( item . Session . HasValue )
451+ {
452+ // Send feedback only if the mini-session id is specified.
453+ // When it's not specified, we consider the predictor doesn't accept feedback.
454+ _singleton . _mockableMethods . OnSuggestionDisplayed ( item . Id , item . Session . Value , num ) ;
448455 }
449456 }
450457 }
@@ -517,9 +524,11 @@ internal override void OnSuggestionAccepted()
517524 if ( _listItems != null && _selectedIndex != - 1 )
518525 {
519526 var item = _listItems [ _selectedIndex ] ;
520- if ( item . PredictorId != Guid . Empty )
527+ if ( item . PredictorSession . HasValue )
521528 {
522- _singleton . _mockableMethods . OnSuggestionAccepted ( item . PredictorId , item . SuggestionText ) ;
529+ // Send feedback only if the mini-session id is specified.
530+ // When it's not specified, we consider the predictor doesn't accept feedback.
531+ _singleton . _mockableMethods . OnSuggestionAccepted ( item . PredictorId , item . PredictorSession . Value , item . SuggestionText ) ;
523532 }
524533 }
525534 }
@@ -577,6 +586,7 @@ internal void UpdateListSelection(int move)
577586 private class PredictionInlineView : PredictionViewBase
578587 {
579588 private Guid _predictorId ;
589+ private uint ? _predictorSession ;
580590 private string _suggestionText ;
581591 private string _lastInputText ;
582592 private bool _alreadyAccepted ;
@@ -613,6 +623,7 @@ internal override void GetSuggestion(string userInput)
613623 {
614624 _suggestionText = GetOneHistorySuggestion ( userInput ) ;
615625 _predictorId = Guid . Empty ;
626+ _predictorSession = null ;
616627 }
617628 }
618629 }
@@ -634,15 +645,27 @@ private void AggregateSuggestions()
634645 continue ;
635646 }
636647
648+ int index = 0 ;
637649 foreach ( var sug in item . Suggestions )
638650 {
639651 if ( sug . SuggestionText != null &&
640652 sug . SuggestionText . StartsWith ( _inputText , _singleton . _options . HistoryStringComparison ) )
641653 {
642654 _predictorId = item . Id ;
655+ _predictorSession = item . Session ;
643656 _suggestionText = sug . SuggestionText ;
657+
658+ if ( _predictorSession . HasValue )
659+ {
660+ // Send feedback only if the mini-session id is specified.
661+ // When it's not specified, we consider the predictor doesn't accept feedback.
662+ _singleton . _mockableMethods . OnSuggestionDisplayed ( _predictorId , _predictorSession . Value , - index ) ;
663+ }
664+
644665 return ;
645666 }
667+
668+ index ++ ;
646669 }
647670 }
648671 }
@@ -673,10 +696,13 @@ internal override void OnSuggestionAccepted()
673696 return ;
674697 }
675698
676- if ( ! _alreadyAccepted && _suggestionText != null && _predictorId != Guid . Empty )
699+ if ( ! _alreadyAccepted && _suggestionText != null && _predictorSession . HasValue )
677700 {
678701 _alreadyAccepted = true ;
679- _singleton . _mockableMethods . OnSuggestionAccepted ( _predictorId , _suggestionText ) ;
702+
703+ // Send feedback only if the mini-session id is specified.
704+ // When it's not specified, we consider the predictor doesn't accept feedback.
705+ _singleton . _mockableMethods . OnSuggestionAccepted ( _predictorId , _predictorSession . Value , _suggestionText ) ;
680706 }
681707 }
682708
@@ -725,6 +751,7 @@ internal override void Reset()
725751 base . Reset ( ) ;
726752 _suggestionText = _lastInputText = null ;
727753 _predictorId = Guid . Empty ;
754+ _predictorSession = null ;
728755 _alreadyAccepted = false ;
729756 }
730757
0 commit comments