Skip to content

Commit

Permalink
fix(codeCompletion): improve auto-complete handling by validating cur…
Browse files Browse the repository at this point in the history
…rent segment
  • Loading branch information
Sma1lboy committed Dec 7, 2024
1 parent fc956e5 commit 068a9c9
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions clients/tabby-agent/src/codeCompletion/contexts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,14 @@ export class CompletionContext {
*/
private handleAutoComplete(request: CompletionRequest): void {
if (!request.autoComplete?.completionItem) return;
// check if the completion item is the same as the curr segment
if (!request.autoComplete.currSeg || !request.autoComplete.completionItem.startsWith(request.autoComplete.currSeg))
return;

this.completionItem = request.autoComplete.completionItem;
this.currSeg = request.autoComplete.currSeg ?? "";
this.insertSeg = request.autoComplete.insertSeg ?? "";

// check if the completion item is the same as the insert segment
if (!this.completionItem.startsWith(this.insertSeg)) {
return;
}

const prefixText = request.text.slice(0, request.position);
const lastIndex = prefixText.lastIndexOf(this.currSeg);

Expand Down

0 comments on commit 068a9c9

Please sign in to comment.