tasks: Add experimental support for user-defined task variables (#13699)
Context: @bennetbo spotted a regression in handling of `cargo run` task in zed repo following a merge of #13658. We've started invoking `cargo run` from the folder of an active file whereas previously we did it from the workspace root. We brainstormed few solutions that involved adding a separate task that gets invoked at a workspace level, but I realized that a cleaner solution may be to finally add user-configured task variables. This way, we can choose which crate to run by default at a workspace level. This has been originally brought up in the context of javascript tasks in https://github.com/zed-industries/zed/pull/12118#issuecomment-2129232114 Note that this is intended for internal use only for the time being. /cc @RemcoSmitsDev we should be unblocked on having runner-dependant tasks now. Release notes: - N/A
This commit is contained in:
parent
065ab93ca7
commit
bac6e2fee7
10 changed files with 108 additions and 25 deletions
|
@ -10861,12 +10861,19 @@ impl Project {
|
|||
cx: &mut ModelContext<Self>,
|
||||
) -> Task<Result<Vec<(TaskSourceKind, TaskTemplate)>>> {
|
||||
if self.is_local() {
|
||||
let language = location
|
||||
.and_then(|location| location.buffer.read(cx).language_at(location.range.start));
|
||||
let (file, language) = location
|
||||
.map(|location| {
|
||||
let buffer = location.buffer.read(cx);
|
||||
(
|
||||
buffer.file().cloned(),
|
||||
buffer.language_at(location.range.start),
|
||||
)
|
||||
})
|
||||
.unwrap_or_default();
|
||||
Task::ready(Ok(self
|
||||
.task_inventory()
|
||||
.read(cx)
|
||||
.list_tasks(language, worktree)))
|
||||
.list_tasks(file, language, worktree, cx)))
|
||||
} else if let Some(project_id) = self
|
||||
.remote_id()
|
||||
.filter(|_| self.ssh_connection_string(cx).is_some())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue