mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-30 06:05:19 +00:00
Remove SplitWithItem
internal action
This commit is contained in:
parent
6857426b78
commit
272039a858
2 changed files with 29 additions and 29 deletions
|
@ -10,7 +10,7 @@ use gpui::{
|
|||
use project::ProjectEntryId;
|
||||
use settings::Settings;
|
||||
|
||||
use crate::{Pane, SplitDirection, SplitWithItem, SplitWithProjectEntry, Workspace};
|
||||
use crate::{Pane, SplitDirection, SplitWithProjectEntry, Workspace};
|
||||
|
||||
use super::DraggedItem;
|
||||
|
||||
|
@ -133,12 +133,21 @@ pub fn handle_dropped_item<V: View>(
|
|||
{
|
||||
let pane_to_split = pane.clone();
|
||||
match action {
|
||||
Action::Move(from, item_id_to_move) => cx.dispatch_action(SplitWithItem {
|
||||
from,
|
||||
item_id_to_move,
|
||||
pane_to_split,
|
||||
split_direction,
|
||||
}),
|
||||
Action::Move(from, item_id_to_move) => {
|
||||
cx.window_context().defer(move |cx| {
|
||||
if let Some(workspace) = workspace.upgrade(cx) {
|
||||
workspace.update(cx, |workspace, cx| {
|
||||
workspace.split_pane_with_item(
|
||||
pane_to_split,
|
||||
split_direction,
|
||||
from,
|
||||
item_id_to_move,
|
||||
cx,
|
||||
);
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
Action::Open(project_entry) => cx.dispatch_action(SplitWithProjectEntry {
|
||||
pane_to_split,
|
||||
split_direction,
|
||||
|
|
|
@ -134,14 +134,6 @@ pub struct OpenPaths {
|
|||
#[derive(Clone, Deserialize, PartialEq)]
|
||||
pub struct ActivatePane(pub usize);
|
||||
|
||||
#[derive(Clone, PartialEq)]
|
||||
pub struct SplitWithItem {
|
||||
pane_to_split: WeakViewHandle<Pane>,
|
||||
split_direction: SplitDirection,
|
||||
from: WeakViewHandle<Pane>,
|
||||
item_id_to_move: usize,
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq)]
|
||||
pub struct SplitWithProjectEntry {
|
||||
pane_to_split: WeakViewHandle<Pane>,
|
||||
|
@ -201,7 +193,7 @@ impl Clone for Toast {
|
|||
|
||||
pub type WorkspaceId = i64;
|
||||
|
||||
impl_internal_actions!(workspace, [SplitWithItem, SplitWithProjectEntry,]);
|
||||
impl_internal_actions!(workspace, [SplitWithProjectEntry]);
|
||||
impl_actions!(workspace, [ActivatePane]);
|
||||
|
||||
pub fn init(app_state: Arc<AppState>, cx: &mut AppContext) {
|
||||
|
@ -307,7 +299,6 @@ pub fn init(app_state: Arc<AppState>, cx: &mut AppContext) {
|
|||
});
|
||||
cx.add_action(Workspace::activate_pane_at_index);
|
||||
|
||||
cx.add_action(Workspace::split_pane_with_item);
|
||||
cx.add_async_action(Workspace::split_pane_with_project_entry);
|
||||
|
||||
cx.add_action(|_: &mut Workspace, _: &install_cli::Install, cx| {
|
||||
|
@ -1735,25 +1726,25 @@ impl Workspace {
|
|||
maybe_pane_handle
|
||||
}
|
||||
|
||||
pub fn split_pane_with_item(&mut self, action: &SplitWithItem, cx: &mut ViewContext<Self>) {
|
||||
let Some(pane_to_split) = action.pane_to_split.upgrade(cx) else { return; };
|
||||
let Some(from) = action.from.upgrade(cx) else { return; };
|
||||
pub fn split_pane_with_item(
|
||||
&mut self,
|
||||
pane_to_split: WeakViewHandle<Pane>,
|
||||
split_direction: SplitDirection,
|
||||
from: WeakViewHandle<Pane>,
|
||||
item_id_to_move: usize,
|
||||
cx: &mut ViewContext<Self>,
|
||||
) {
|
||||
let Some(pane_to_split) = pane_to_split.upgrade(cx) else { return; };
|
||||
let Some(from) = from.upgrade(cx) else { return; };
|
||||
if &pane_to_split == self.dock_pane() {
|
||||
warn!("Can't split dock pane.");
|
||||
return;
|
||||
}
|
||||
|
||||
let new_pane = self.add_pane(cx);
|
||||
Pane::move_item(
|
||||
self,
|
||||
from.clone(),
|
||||
new_pane.clone(),
|
||||
action.item_id_to_move,
|
||||
0,
|
||||
cx,
|
||||
);
|
||||
Pane::move_item(self, from.clone(), new_pane.clone(), item_id_to_move, 0, cx);
|
||||
self.center
|
||||
.split(&pane_to_split, &new_pane, action.split_direction)
|
||||
.split(&pane_to_split, &new_pane, split_direction)
|
||||
.unwrap();
|
||||
cx.notify();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue