Remove SplitWithProjectEntry
internal action
This commit is contained in:
parent
272039a858
commit
4bcba487c5
2 changed files with 24 additions and 24 deletions
|
@ -10,7 +10,7 @@ use gpui::{
|
||||||
use project::ProjectEntryId;
|
use project::ProjectEntryId;
|
||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
|
|
||||||
use crate::{Pane, SplitDirection, SplitWithProjectEntry, Workspace};
|
use crate::{Pane, SplitDirection, Workspace};
|
||||||
|
|
||||||
use super::DraggedItem;
|
use super::DraggedItem;
|
||||||
|
|
||||||
|
@ -148,11 +148,22 @@ pub fn handle_dropped_item<V: View>(
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Action::Open(project_entry) => cx.dispatch_action(SplitWithProjectEntry {
|
Action::Open(project_entry) => {
|
||||||
pane_to_split,
|
cx.window_context().defer(move |cx| {
|
||||||
split_direction,
|
if let Some(workspace) = workspace.upgrade(cx) {
|
||||||
project_entry,
|
workspace.update(cx, |workspace, cx| {
|
||||||
}),
|
if let Some(task) = workspace.split_pane_with_project_entry(
|
||||||
|
pane_to_split,
|
||||||
|
split_direction,
|
||||||
|
project_entry,
|
||||||
|
cx,
|
||||||
|
) {
|
||||||
|
task.detach_and_log_err(cx);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
match action {
|
match action {
|
||||||
|
|
|
@ -37,7 +37,7 @@ use gpui::{
|
||||||
rect::RectF,
|
rect::RectF,
|
||||||
vector::{vec2f, Vector2F},
|
vector::{vec2f, Vector2F},
|
||||||
},
|
},
|
||||||
impl_actions, impl_internal_actions,
|
impl_actions,
|
||||||
keymap_matcher::KeymapContext,
|
keymap_matcher::KeymapContext,
|
||||||
platform::{
|
platform::{
|
||||||
CursorStyle, MouseButton, PathPromptOptions, Platform, PromptLevel, WindowBounds,
|
CursorStyle, MouseButton, PathPromptOptions, Platform, PromptLevel, WindowBounds,
|
||||||
|
@ -134,13 +134,6 @@ pub struct OpenPaths {
|
||||||
#[derive(Clone, Deserialize, PartialEq)]
|
#[derive(Clone, Deserialize, PartialEq)]
|
||||||
pub struct ActivatePane(pub usize);
|
pub struct ActivatePane(pub usize);
|
||||||
|
|
||||||
#[derive(Clone, PartialEq)]
|
|
||||||
pub struct SplitWithProjectEntry {
|
|
||||||
pane_to_split: WeakViewHandle<Pane>,
|
|
||||||
split_direction: SplitDirection,
|
|
||||||
project_entry: ProjectEntryId,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct Toast {
|
pub struct Toast {
|
||||||
id: usize,
|
id: usize,
|
||||||
msg: Cow<'static, str>,
|
msg: Cow<'static, str>,
|
||||||
|
@ -193,7 +186,6 @@ impl Clone for Toast {
|
||||||
|
|
||||||
pub type WorkspaceId = i64;
|
pub type WorkspaceId = i64;
|
||||||
|
|
||||||
impl_internal_actions!(workspace, [SplitWithProjectEntry]);
|
|
||||||
impl_actions!(workspace, [ActivatePane]);
|
impl_actions!(workspace, [ActivatePane]);
|
||||||
|
|
||||||
pub fn init(app_state: Arc<AppState>, cx: &mut AppContext) {
|
pub fn init(app_state: Arc<AppState>, cx: &mut AppContext) {
|
||||||
|
@ -299,8 +291,6 @@ pub fn init(app_state: Arc<AppState>, cx: &mut AppContext) {
|
||||||
});
|
});
|
||||||
cx.add_action(Workspace::activate_pane_at_index);
|
cx.add_action(Workspace::activate_pane_at_index);
|
||||||
|
|
||||||
cx.add_async_action(Workspace::split_pane_with_project_entry);
|
|
||||||
|
|
||||||
cx.add_action(|_: &mut Workspace, _: &install_cli::Install, cx| {
|
cx.add_action(|_: &mut Workspace, _: &install_cli::Install, cx| {
|
||||||
cx.spawn(|workspace, mut cx| async move {
|
cx.spawn(|workspace, mut cx| async move {
|
||||||
let err = install_cli::install_cli(&cx)
|
let err = install_cli::install_cli(&cx)
|
||||||
|
@ -1751,10 +1741,12 @@ impl Workspace {
|
||||||
|
|
||||||
pub fn split_pane_with_project_entry(
|
pub fn split_pane_with_project_entry(
|
||||||
&mut self,
|
&mut self,
|
||||||
action: &SplitWithProjectEntry,
|
pane_to_split: WeakViewHandle<Pane>,
|
||||||
|
split_direction: SplitDirection,
|
||||||
|
project_entry: ProjectEntryId,
|
||||||
cx: &mut ViewContext<Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
) -> Option<Task<Result<()>>> {
|
) -> Option<Task<Result<()>>> {
|
||||||
let pane_to_split = action.pane_to_split.upgrade(cx)?;
|
let pane_to_split = pane_to_split.upgrade(cx)?;
|
||||||
if &pane_to_split == self.dock_pane() {
|
if &pane_to_split == self.dock_pane() {
|
||||||
warn!("Can't split dock pane.");
|
warn!("Can't split dock pane.");
|
||||||
return None;
|
return None;
|
||||||
|
@ -1762,13 +1754,10 @@ impl Workspace {
|
||||||
|
|
||||||
let new_pane = self.add_pane(cx);
|
let new_pane = self.add_pane(cx);
|
||||||
self.center
|
self.center
|
||||||
.split(&pane_to_split, &new_pane, action.split_direction)
|
.split(&pane_to_split, &new_pane, split_direction)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let path = self
|
let path = self.project.read(cx).path_for_entry(project_entry, cx)?;
|
||||||
.project
|
|
||||||
.read(cx)
|
|
||||||
.path_for_entry(action.project_entry, cx)?;
|
|
||||||
let task = self.open_path(path, Some(new_pane.downgrade()), true, cx);
|
let task = self.open_path(path, Some(new_pane.downgrade()), true, cx);
|
||||||
Some(cx.foreground().spawn(async move {
|
Some(cx.foreground().spawn(async move {
|
||||||
task.await?;
|
task.await?;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue