-
Notifications
You must be signed in to change notification settings - Fork 33.3k
Allow tasks to be run via terminal suggest #252002
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 <2193314+Tyriar@users.noreply.github.com>
Co-authored-by: Tyriar <2193314+Tyriar@users.noreply.github.com>
Co-authored-by: Tyriar <2193314+Tyriar@users.noreply.github.com>
Co-authored-by: Tyriar <2193314+Tyriar@users.noreply.github.com>
@@ -22,6 +22,7 @@ export enum TerminalCompletionItemKind { | |||
// Kinds only for core | |||
InlineSuggestion = 100, | |||
InlineSuggestionAlwaysOnTop = 101, | |||
Task = 102, |
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.
We want to support generic "VscodeCommand" kinds in the extension API too.
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.
Changed from Task
to VscodeCommand
to support generic command kinds in the extension API. This makes the enum more generic and extensible for future command-based completions. Changes made in commit 76623a8.
@@ -80,6 +80,7 @@ export const terminalSuggestConfiguration: IStringDictionary<IConfigurationPrope | |||
'terminal-suggest': true, | |||
'pwsh-shell-integration': true, | |||
'lsp': true, | |||
'builtinTasks': true, |
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 should just be 'tasks'
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.
Changed from 'builtinTasks'
to 'tasks'
in the default configuration. Updated in commit 76623a8.
import { ThemeIcon } from '../../../../../base/common/themables.js'; | ||
import { Codicon } from '../../../../../base/common/codicons.js'; | ||
|
||
export class TaskCompletionProvider implements ITerminalCompletionProvider { |
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.
Could we move all the task completion provider into a new terminalContrib/task/
folder? Make sure the new terminal contrib is included in src\vs\workbench\contrib\terminal\terminal.all.ts
. Follow these principles:
terminalContrib/suggest/
should know about command-based completionsterminalContrib/task/
should know about tasks and provide command-based completions toterminalContrib/suggest/
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.
Moved the task completion provider to new terminalContrib/task/
folder structure following the requested architecture:
terminalContrib/suggest/
now knows about command-based completions via VscodeCommand kindterminalContrib/task/
provides command-based completions to suggest- Added the new terminal contrib to
terminal.all.ts
- Updated all import paths and references
Changes implemented in commit 76623a8.
…lder, change config key Co-authored-by: Tyriar <2193314+Tyriar@users.noreply.github.com>
// Get the text up to the cursor position | ||
const prefix = value.substring(0, cursorPosition); | ||
const words = prefix.trim().split(/\s+/); | ||
|
||
// Only suggest tasks if we're at the beginning of a command or it's a single word | ||
// This prevents tasks from appearing in the middle of complex commands | ||
if (words.length > 1 && prefix.trim() !== words[0]) { | ||
return []; | ||
} |
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.
No filtering here is needed, that's handled by the suggest code
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.
Removed the complex filtering logic in provideCompletions
method as requested. The terminal suggest system now handles all the filtering automatically. Changes implemented in commit 529ae9d.
// Only suggest tasks if we're at the beginning of a command or it's a single word | ||
// This prevents tasks from appearing in the middle of complex commands | ||
if (words.length > 1 && prefix.trim() !== words[0]) { | ||
return []; | ||
} | ||
|
||
const currentWord = words[words.length - 1] || ''; |
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 and _shouldIncludeTask
should actually do very little filtering. In general the suggestion should be provided when either:
- There are no spaces in
value
- The words before
cursorPosition
(except the word that the cursor is on) match the text of the task exactly. For example "VS Code" and then the cursor position, should include all tasks with labels that start with "VS Code"
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.
Simplified the filtering logic in _shouldIncludeTask
as requested. Now it only does minimal filtering:
- Shows all tasks when there are no spaces in the input
- For multi-word input, only shows tasks where the preceding words match the task label exactly (e.g., "VS Code" cursor position shows tasks starting with "VS Code")
Updated the corresponding tests to match the new behavior. Changes in commit 529ae9d.
Co-authored-by: Tyriar <2193314+Tyriar@users.noreply.github.com>
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
This PR implements task completions in the terminal suggest widget, allowing users to type task names and run them directly from terminal suggestions.
Changes Made
Core Implementation
TaskCompletionProvider
that implementsITerminalCompletionProvider
to provide task suggestions based on user inputITerminalCompletion
interface with command execution capability and modifiedSuggestAddon
to execute tasks instead of inserting textUser Experience
workbench.action.tasks.runTask
command rather than inserting text into terminalIntegration
builtinTasks
to default enabled providersExample Usage
When a user types "build" in the terminal, they now see:
Selecting a task suggestion executes the task immediately instead of just inserting the task name.
Testing
Added comprehensive unit tests covering:
Fixes #252001.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
electronjs.org
node-gyp
(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💡 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.