Update IntelliCode star prefix removal to handle all cases

Co-authored-by: anthonykim1 <62267334+anthonykim1@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2025-07-31 21:37:54 +00:00
parent 01fa7d9ff6
commit 003be7802c
2 changed files with 14 additions and 5 deletions

View File

@ -905,8 +905,12 @@ export class SuggestAddon extends Disposable implements ITerminalAddon, ISuggest
let completionText = typeof completion.label === 'string' ? completion.label : completion.label.label;
// Strip star prefix from IntelliCode starred suggestions when using label as completion text
if (completionText.startsWith('★ ')) {
completionText = completionText.substring(2); // Remove "★ " prefix
if (completionText.startsWith('★')) {
completionText = completionText.substring(1); // Remove "★" prefix
// Also remove a following space if present for clean formatting
if (completionText.startsWith(' ')) {
completionText = completionText.substring(1);
}
}
if ((completion.kind === TerminalCompletionItemKind.Folder || completion.isFileOverride) && completionText.includes(' ')) {
// Escape spaces in files or folders so they're valid paths

View File

@ -42,8 +42,9 @@ suite('Terminal Suggest Addon - IntelliCode Star Prefix Handling', () => {
const testCases = [
{ input: '★ chdir', expected: 'chdir' },
{ input: '★ print', expected: 'print' },
{ input: '★chdir', expected: 'chdir' }, // No space after star
{ input: '★.chdir', expected: '.chdir' }, // Dot after star
{ input: 'normal_completion', expected: 'normal_completion' },
{ input: '★invalid', expected: '★invalid' }, // No space after star
{ input: '* starred', expected: '* starred' }, // Different star character
{ input: '', expected: '' },
];
@ -51,8 +52,12 @@ suite('Terminal Suggest Addon - IntelliCode Star Prefix Handling', () => {
testCases.forEach(({ input, expected }) => {
let completionText = input;
// This is the exact logic from the fix
if (completionText.startsWith('★ ')) {
completionText = completionText.substring(2); // Remove "★ " prefix
if (completionText.startsWith('★')) {
completionText = completionText.substring(1); // Remove "★" prefix
// Also remove a following space if present for clean formatting
if (completionText.startsWith(' ')) {
completionText = completionText.substring(1);
}
}
strictEqual(completionText, expected, `Failed for input: "${input}"`);
});