Skip to content

Commit

Permalink
Imporve code completion variable naming (#14467)
Browse files Browse the repository at this point in the history
fixed #14466
  • Loading branch information
JonasHelming authored Nov 19, 2024
1 parent ef33e14 commit e191e18
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/ai-code-completion/src/common/code-completion-agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ export class CodeCompletionAgentImpl implements CodeCompletionAgent {
}

// Get text until the given position
const textUntilCurrentPosition = model.getValueInRange({
const prefix = model.getValueInRange({
startLineNumber: 1,
startColumn: 1,
endLineNumber: position.lineNumber,
endColumn: position.column,
});

// Get text after the given position
const textAfterCurrentPosition = model.getValueInRange({
const suffix = model.getValueInRange({
startLineNumber: position.lineNumber,
startColumn: position.column,
endLineNumber: model.getLineCount(),
Expand All @@ -71,7 +71,7 @@ export class CodeCompletionAgentImpl implements CodeCompletionAgent {
return undefined;
}
const prompt = await this.promptService
.getPrompt('code-completion-prompt', { textUntilCurrentPosition, textAfterCurrentPosition, file, language })
.getPrompt('code-completion-prompt', { prefix, suffix, file, language })
.then(p => p?.text);
if (!prompt) {
this.logger.error('No prompt found for code-completion-agent');
Expand Down Expand Up @@ -138,7 +138,7 @@ export class CodeCompletionAgentImpl implements CodeCompletionAgent {
The language of the file is {{language}}. Return your result as plain text without markdown formatting.
Finish the following code snippet.
{{textUntilCurrentPosition}}[[MARKER]]{{textAfterCurrentPosition}}
{{prefix}}[[MARKER]]{{suffix}}
Only return the exact replacement for [[MARKER]] to complete the snippet.`,
},
Expand All @@ -154,8 +154,8 @@ Only return the exact replacement for [[MARKER]] to complete the snippet.`,
readonly agentSpecificVariables: AgentSpecificVariables[] = [
{ name: 'file', usedInPrompt: true, description: 'The uri of the file being edited.' },
{ name: 'language', usedInPrompt: true, description: 'The languageId of the file being edited.' },
{ name: 'textUntilCurrentPosition', usedInPrompt: true, description: 'The code before the current position of the cursor.' },
{ name: 'textAfterCurrentPosition', usedInPrompt: true, description: 'The code after the current position of the cursor.' }
{ name: 'prefix', usedInPrompt: true, description: 'The code before the current position of the cursor.' },
{ name: 'suffix', usedInPrompt: true, description: 'The code after the current position of the cursor.' }
];
readonly tags?: string[] | undefined;
}

0 comments on commit e191e18

Please sign in to comment.