@@ -12,19 +12,10 @@ import {
12
12
import { CancellationToken , InlineCompletionContext , Position , TextDocument } from 'vscode'
13
13
import { LanguageClient } from 'vscode-languageclient'
14
14
import { SessionManager } from './sessionManager'
15
- import {
16
- AuthUtil ,
17
- CodeWhispererConstants ,
18
- CodeWhispererStatusBarManager ,
19
- vsCodeState ,
20
- } from 'aws-core-vscode/codewhisperer'
15
+ import { AuthUtil , CodeWhispererStatusBarManager , vsCodeState } from 'aws-core-vscode/codewhisperer'
21
16
import { TelemetryHelper } from './telemetryHelper'
22
17
import { ICursorUpdateRecorder } from './cursorUpdateManager'
23
18
import { getLogger } from 'aws-core-vscode/shared'
24
- import { DocumentEventListener } from './documentEventListener'
25
- import { getOpenFilesInWindow } from 'aws-core-vscode/utils'
26
- import { asyncCallWithTimeout } from '../../util/timeoutUtil'
27
- import { EditSuggestionState } from './editSuggestionState'
28
19
29
20
export interface GetAllRecommendationsOptions {
30
21
emitTelemetry ?: boolean
@@ -120,53 +111,11 @@ export class RecommendationService {
120
111
} ,
121
112
} )
122
113
const t0 = performance . now ( )
123
-
124
- // Best effort estimate of deletion
125
- const isTriggerByDeletion = documentEventListener . isLastEventDeletion ( document . uri . fsPath )
126
-
127
- const ps : Promise < InlineCompletionListWithReferences > [ ] = [ ]
128
- /**
129
- * IsTriggerByDeletion is to prevent user deletion invoking Completions.
130
- * PartialResultToken is not a hack for now since only Edits suggestion use partialResultToken across different calls of [getAllRecommendations],
131
- * Completions use PartialResultToken with single 1 call of [getAllRecommendations].
132
- * Edits leverage partialResultToken to achieve EditStreak such that clients can pull all continuous suggestions generated by the model within 1 EOS block.
133
- */
134
- if ( ! isTriggerByDeletion && ! request . partialResultToken && ! EditSuggestionState . isEditSuggestionActive ( ) ) {
135
- const completionPromise : Promise < InlineCompletionListWithReferences > = languageClient . sendRequest (
136
- inlineCompletionWithReferencesRequestType . method ,
137
- request ,
138
- token
139
- )
140
- ps . push ( completionPromise )
141
- }
142
-
143
- /**
144
- * Though Edit request is sent on keystrokes everytime, the language server will execute the request in a debounced manner so that it won't be immediately executed.
145
- */
146
- const editPromise : Promise < InlineCompletionListWithReferences > = languageClient . sendRequest (
147
- editCompletionRequestType . method ,
114
+ const result : InlineCompletionListWithReferences = await languageClient . sendRequest (
115
+ inlineCompletionWithReferencesRequestType . method ,
148
116
request ,
149
117
token
150
118
)
151
- ps . push ( editPromise )
152
-
153
- /**
154
- * First come first serve, ideally we should simply return the first response returned. However there are some caviar here because either
155
- * (1) promise might be returned early without going through service
156
- * (2) some users are not enabled with edits suggestion, therefore service will return empty result without passing through the model
157
- * With the scenarios listed above or others, it's possible that 1 promise will ALWAYS win the race and users will NOT get any suggestion back.
158
- * This is the hack to return first "NON-EMPTY" response
159
- */
160
- let result = await Promise . race ( ps )
161
- if ( ps . length > 1 && result . items . length === 0 ) {
162
- for ( const p of ps ) {
163
- const r = await p
164
- if ( r . items . length > 0 ) {
165
- result = r
166
- }
167
- }
168
- }
169
-
170
119
getLogger ( ) . info ( 'Received inline completion response from LSP: %O' , {
171
120
sessionId : result . sessionId ,
172
121
latency : performance . now ( ) - t0 ,
@@ -199,6 +148,7 @@ export class RecommendationService {
199
148
200
149
const isInlineEdit = result . items . some ( ( item ) => item . isInlineEdit )
201
150
151
+ // TODO: question, is it possible that the first request returns empty suggestion but has non-empty next token?
202
152
if ( result . partialResultToken ) {
203
153
if ( ! isInlineEdit ) {
204
154
// If the suggestion is COMPLETIONS and there are more results to fetch, handle them in the background
@@ -249,7 +199,11 @@ export class RecommendationService {
249
199
while ( nextToken ) {
250
200
const request = { ...initialRequest , partialResultToken : nextToken }
251
201
252
- const result = await this . getRecommendationsWithTimeout ( languageClient , request , token )
202
+ const result : InlineCompletionListWithReferences = await languageClient . sendRequest (
203
+ inlineCompletionWithReferencesRequestType . method ,
204
+ request ,
205
+ token
206
+ )
253
207
// when pagination is in progress, but user has already accepted or rejected an inline completion
254
208
// then stop pagination
255
209
if ( this . sessionManager . getActiveSession ( ) === undefined || vsCodeState . isCodeWhispererEditing ) {
0 commit comments