chore: Sever terminal_view <-> tasks_ui dependency (#20946)

Closes #ISSUE

Release Notes:

- N/A
This commit is contained in:
Piotr Osiewicz 2024-11-21 01:07:14 +01:00 committed by GitHub
parent cbba44900d
commit 536d7e5355
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 56 additions and 53 deletions

View file

@ -25,7 +25,7 @@ ui.workspace = true
util.workspace = true
workspace.workspace = true
language.workspace = true
zed_actions.workspace = true
[dev-dependencies]
editor = { workspace = true, features = ["test-support"] }

View file

@ -3,6 +3,7 @@ use editor::{tasks::task_context, Editor};
use gpui::{AppContext, Task as AsyncTask, ViewContext, WindowContext};
use modal::TasksModal;
use project::{Location, WorktreeId};
use task::TaskId;
use workspace::tasks::schedule_task;
use workspace::{tasks::schedule_resolved_task, Workspace};
@ -25,9 +26,13 @@ pub fn init(cx: &mut AppContext) {
.read(cx)
.task_inventory()
.and_then(|inventory| {
inventory
.read(cx)
.last_scheduled_task(action.task_id.as_ref())
inventory.read(cx).last_scheduled_task(
action
.task_id
.as_ref()
.map(|id| TaskId(id.clone()))
.as_ref(),
)
})
{
if action.reevaluate_context {

View file

@ -3,13 +3,13 @@ use std::sync::Arc;
use crate::active_item_selection_properties;
use fuzzy::{StringMatch, StringMatchCandidate};
use gpui::{
impl_actions, rems, Action, AnyElement, AppContext, DismissEvent, EventEmitter, FocusableView,
rems, Action, AnyElement, AppContext, DismissEvent, EventEmitter, FocusableView,
InteractiveElement, Model, ParentElement, Render, SharedString, Styled, Subscription, Task,
View, ViewContext, VisualContext, WeakView,
};
use picker::{highlighted_match_with_paths::HighlightedText, Picker, PickerDelegate};
use project::{task_store::TaskStore, TaskSourceKind};
use task::{ResolvedTask, TaskContext, TaskId, TaskTemplate};
use task::{ResolvedTask, TaskContext, TaskTemplate};
use ui::{
div, h_flex, v_flex, ActiveTheme, Button, ButtonCommon, ButtonSize, Clickable, Color,
FluentBuilder as _, Icon, IconButton, IconButtonShape, IconName, IconSize, IntoElement,
@ -18,48 +18,7 @@ use ui::{
};
use util::ResultExt;
use workspace::{tasks::schedule_resolved_task, ModalView, Workspace};
use serde::Deserialize;
/// Spawn a task with name or open tasks modal
#[derive(PartialEq, Clone, Deserialize, Default)]
pub struct Spawn {
#[serde(default)]
/// Name of the task to spawn.
/// If it is not set, a modal with a list of available tasks is opened instead.
/// Defaults to None.
pub task_name: Option<String>,
}
impl Spawn {
pub fn modal() -> Self {
Self { task_name: None }
}
}
/// Rerun last task
#[derive(PartialEq, Clone, Deserialize, Default)]
pub struct Rerun {
/// Controls whether the task context is reevaluated prior to execution of a task.
/// If it is not, environment variables such as ZED_COLUMN, ZED_FILE are gonna be the same as in the last execution of a task
/// If it is, these variables will be updated to reflect current state of editor at the time task::Rerun is executed.
/// default: false
#[serde(default)]
pub reevaluate_context: bool,
/// Overrides `allow_concurrent_runs` property of the task being reran.
/// Default: null
#[serde(default)]
pub allow_concurrent_runs: Option<bool>,
/// Overrides `use_new_terminal` property of the task being reran.
/// Default: null
#[serde(default)]
pub use_new_terminal: Option<bool>,
/// If present, rerun the task with this ID, otherwise rerun the last task.
pub task_id: Option<TaskId>,
}
impl_actions!(task, [Rerun, Spawn]);
pub use zed_actions::{Rerun, Spawn};
/// A modal used to spawn new tasks.
pub(crate) struct TasksModalDelegate {