Skip to content

Terminal suggest: Support fig additionalSuggestions with proper insertValue handling #260696

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 9, 2025

This PR implements support for fig's additionalSuggestions feature in the VS Code terminal suggestion system. The additionalSuggestions field allows completion specs to provide shortcut suggestions alongside regular subcommands.

What this enables

With this change, when typing git in the terminal, users will now see additional completion suggestions like:

commit -m ''     Git commit shortcut
quick-commit

The additional suggestions provide quick access to common command patterns with proper text replacement.

Implementation details

  • Added addAdditionalSuggestions function that processes both string and object suggestions from the additionalSuggestions array in fig specs
  • Integrated with existing suggestion flow by processing additional suggestions when SuggestionFlag.Subcommands is set
  • Proper insertValue handling with {cursor} placeholder replacement for command shortcuts
  • Visual differentiation using TerminalCompletionItemKind.Alias for suggestions that specify an icon property

The implementation handles both simple string suggestions and full suggestion objects with properties like name, description, insertValue, and icon. When an insertValue is provided, it replaces the {cursor} placeholder with an empty string since VS Code terminal completions don't support cursor positioning.

Example from git.ts spec

additionalSuggestions: [
  {
    name: "commit -m 'msg'",
    description: "Git commit shortcut",
    insertValue: "commit -m '{cursor}'",
    icon: "fig://template?color=2ecc71&badge=🔥",
  },
]

This creates a completion that shows "commit -m ''" as the replacement text, allowing users to quickly insert the command template.

Testing

Updated test coverage to verify the processing logic handles both object and string additional suggestions with proper insertValue replacement.

Fixes #239627.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@Copilot Copilot AI changed the title [WIP] Terminal suggest: Support fig additionalSuggestions Terminal suggest: Support fig additionalSuggestions Aug 9, 2025
Copilot finished work on behalf of Tyriar August 9, 2025 00:35
@Copilot Copilot AI requested a review from Tyriar August 9, 2025 00:35
Comment on lines 388 to 394
// Handle icon property (fig://... icons are not directly supported yet,
// but we can use a lightbulb icon for additionalSuggestions)
if (suggestion.icon) {
// Note: Custom icons from fig (fig://...) are not yet supported.
// Using lightbulb outline icon as mentioned in issue #239706
completionItem.icon = new vscode.ThemeIcon('lightbulb');
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this causes a compile error

Property 'icon' does not exist on type 'TerminalCompletionItem'.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed the compilation error in commit 2191351. Removed the invalid icon property assignment since TerminalCompletionItem doesn't have an icon property. Instead, I use TerminalCompletionItemKind.Alias for suggestions with icons to provide visual differentiation.

Comment on lines +343 to 346
if (parsedArguments.completionObj.additionalSuggestions) {
await addAdditionalSuggestions(parsedArguments.completionObj.additionalSuggestions, terminalContext, prefix, items);
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the cursor replacement doesn't work

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed the cursor replacement in commit 2191351. Now properly handles the insertValue property and replaces {cursor} placeholder with empty string. For example, insertValue: "commit -m '{cursor}'" now correctly becomes "commit -m ''" in the completion.

@Tyriar
Copy link
Member

Tyriar commented Aug 9, 2025

@copilot fix review comments above

@Copilot Copilot AI changed the title Terminal suggest: Support fig additionalSuggestions Terminal suggest: Support fig additionalSuggestions with proper insertValue handling Aug 9, 2025
@Copilot Copilot AI requested a review from Tyriar August 9, 2025 01:21
Copilot finished work on behalf of Tyriar August 9, 2025 01:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Terminal suggest: Support fig additionalSuggestions
2 participants