-
Notifications
You must be signed in to change notification settings - Fork 34.2k
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: Tyriar <[email protected]>
Co-authored-by: Tyriar <[email protected]>
// 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'); | ||
} |
There was a problem hiding this comment.
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'.
There was a problem hiding this comment.
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.
if (parsedArguments.completionObj.additionalSuggestions) { | ||
await addAdditionalSuggestions(parsedArguments.completionObj.additionalSuggestions, terminalContext, prefix, items); | ||
} | ||
} |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
@copilot fix review comments above |
Co-authored-by: Tyriar <[email protected]>
This PR implements support for fig's
additionalSuggestions
feature in the VS Code terminal suggestion system. TheadditionalSuggestions
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:The additional suggestions provide quick access to common command patterns with proper text replacement.
Implementation details
addAdditionalSuggestions
function that processes both string and object suggestions from theadditionalSuggestions
array in fig specsSuggestionFlag.Subcommands
is set{cursor}
placeholder replacement for command shortcutsTerminalCompletionItemKind.Alias
for suggestions that specify an icon propertyThe implementation handles both simple string suggestions and full suggestion objects with properties like
name
,description
,insertValue
, andicon
. When aninsertValue
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
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.