Skip to content

Commit d1307f2

Browse files
authored
fix(codewhisperer): extra space at the beginning of ghost text #3486
Problem: When user types with SPACE at certain speed, both the service and user will add extra SPACE after the CodeWhisperer invocation position, resulting in multiple extra space at the start of the suggestion ghost text, which breaks the indentation of the current file. The root cause is an old mechanism that moves the invocation start position if the user typeahead is while-space characters. Solution: Remove the old start position moving mechanism. Make sure the space is included in the typeahead computation.
1 parent 8c4244d commit d1307f2

File tree

3 files changed

+4
-10
lines changed

3 files changed

+4
-10
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Bug Fix",
3+
"description": "CodeWhisperer sometimes add extra space at the beginning of suggestion"
4+
}

src/codewhisperer/service/inlineCompletionService.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,6 @@ export class InlineCompletionService {
382382
RecommendationHandler.instance.reportUserDecisionOfRecommendation(editor, -1)
383383
RecommendationHandler.instance.clearRecommendations()
384384
} else if (RecommendationHandler.instance.recommendations.length > 0) {
385-
RecommendationHandler.instance.moveStartPositionToSkipSpaces(editor)
386385
this.subscribeSuggestionCommands()
387386
await this.startRejectionTimer(editor)
388387
await this.showRecommendation(0, true)

src/codewhisperer/service/recommendationHandler.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -412,15 +412,6 @@ export class RecommendationHandler {
412412
return true
413413
}
414414

415-
moveStartPositionToSkipSpaces(editor: vscode.TextEditor) {
416-
const start = this.startPos
417-
const prefix = editor.document.getText(new vscode.Range(start, editor.selection.active))
418-
// skip space from invocation position
419-
if (prefix.length > 0 && prefix.trimStart().length != prefix.length) {
420-
this.startPos = start.translate(undefined, prefix.length - prefix.trimStart().length)
421-
}
422-
}
423-
424415
async onThrottlingException(awsError: AWSError, triggerType: CodewhispererTriggerType) {
425416
if (
426417
awsError.code === 'ThrottlingException' &&

0 commit comments

Comments
 (0)