Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 37 additions & 1 deletion app/src/code/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use crate::terminal::cli_agent::{
};
use crate::terminal::view::CliAgentRouting;
use crate::workspace::util::get_context_target_terminal_view;
use crate::workspace::TabBarDropTargetData;
use crate::workspace::{TabBarDropTargetData, VerticalTabsPaneDropTargetData};
use crate::{code::EditorTabBarDropTargetData, pane_group::pane::ActionOrigin};
use lsp::LspManagerModel;
use pathfinder_color::ColorU;
Expand Down Expand Up @@ -634,6 +634,10 @@ impl CodeView {
})
}

pub fn local_paths(&self) -> Vec<PathBuf> {
self.tab_group.iter().filter_map(TabData::path).collect()
}

pub fn pane_configuration(&self) -> ModelHandle<PaneConfiguration> {
self.pane_configuration.clone()
}
Expand Down Expand Up @@ -1581,6 +1585,26 @@ impl CodeView {
precomputed_tab_hover_index: None,
},
);
} else if let Some(data) = data.and_then(|data| {
data.as_any()
.downcast_ref::<VerticalTabsPaneDropTargetData>()
}) {
// If an editor tab is dragged over the vertical workspace tab bar, we should clear
// all drag indicators on the editor tab group.
ctx.dispatch_typed_action(
PaneHeaderAction::<CodeViewAction, CodeViewAction>::CustomAction(
CodeViewAction::ClearEditorTabGroupDragPositions,
),
);

ctx.dispatch_typed_action(
PaneHeaderAction::<CodeViewAction, CodeViewAction>::PaneHeaderDragged {
origin: ActionOrigin::EditorTab(index),
drag_location: PaneDragDropLocation::TabBar(data.tab_bar_location),
drag_position,
precomputed_tab_hover_index: Some(data.tab_hover_index),
},
);
} else {
// If an editor tab is dragged anywhere else, we should clear all drag indicators on the editor and workspace tab groups.
ctx.dispatch_typed_action(
Expand Down Expand Up @@ -1615,6 +1639,18 @@ impl CodeView {
PaneHeaderAction::<CodeViewAction, CodeViewAction>::PaneHeaderDropped {
origin: ActionOrigin::EditorTab(index),
drop_location: PaneDragDropLocation::TabBar(data.tab_bar_location),
visual_tab_order: None,
},
);
} else if let Some(data) = data.and_then(|data| {
data.as_any()
.downcast_ref::<VerticalTabsPaneDropTargetData>()
}) {
ctx.dispatch_typed_action(
PaneHeaderAction::<CodeViewAction, CodeViewAction>::PaneHeaderDropped {
origin: ActionOrigin::EditorTab(index),
drop_location: PaneDragDropLocation::TabBar(data.tab_bar_location),
visual_tab_order: data.visual_tab_order.clone(),
},
);
}
Expand Down
4 changes: 4 additions & 0 deletions app/src/code/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ impl CodeView {
None
}

pub fn local_paths(&self) -> Vec<PathBuf> {
Vec::new()
}

pub fn focus(&self, _ctx: &mut ViewContext<Self>) {}

pub fn pane_configuration(&self) -> ModelHandle<PaneConfiguration> {
Expand Down
7 changes: 6 additions & 1 deletion app/src/pane_group/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,7 @@ pub enum Event {
DroppedOnTabBar {
origin: ActionOrigin,
pane_id: PaneId,
visual_tab_order: Option<Vec<usize>>,
},
/// Switches the focus to the specified tab and moves the given
/// pane_id into the tab as a hidden pane. This will insert it into the pane
Expand Down Expand Up @@ -1147,10 +1148,14 @@ impl PaneGroup {
ctx.emit(Event::ClearHoveredTabIndex);
self.move_pane(pane_id, *target_id, *direction, ctx);
}
PaneViewEvent::DroppedOnTabBar { origin } => {
PaneViewEvent::DroppedOnTabBar {
origin,
visual_tab_order,
} => {
ctx.emit(Event::DroppedOnTabBar {
origin: *origin,
pane_id,
visual_tab_order: visual_tab_order.clone(),
});
ctx.emit(Event::ClearHoveredTabIndex);
}
Expand Down
20 changes: 14 additions & 6 deletions app/src/pane_group/pane/view/header/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ pub enum Event<A: ActionPayload, B: ActionPayload> {
/// A pane or file tab was dropped on the workspace tab bar.
DroppedOnTabBar {
origin: ActionOrigin,
visual_tab_order: Option<Vec<usize>>,
},
// This header was dropped on a place outside of the pane group or tab bar
PaneDroppedOutsideofTabBarOrPaneGroup,
Expand Down Expand Up @@ -116,6 +117,7 @@ pub enum PaneHeaderAction<A: ActionPayload, B: ActionPayload> {
PaneHeaderDropped {
origin: ActionOrigin,
drop_location: PaneDragDropLocation, // Represents what kind of drop target the pane was dropped over
visual_tab_order: Option<Vec<usize>>,
},
PaneHeaderClicked,
}
Expand Down Expand Up @@ -913,11 +915,9 @@ impl<P: BackingView> TypedActionView for PaneHeader<P> {
ctx,
)
}),
hidden_pane_preview_direction: if precomputed_tab_hover_index.is_some() {
Direction::Up
} else {
Direction::Left
},
// Precomputed hover indices are supplied by vertical tabs, whose over-tab
// drop path commits the same left root split.
hidden_pane_preview_direction: Direction::Left,
});
}
PaneDragDropLocation::PaneGroup(target_id) => {
Expand Down Expand Up @@ -945,11 +945,15 @@ impl<P: BackingView> TypedActionView for PaneHeader<P> {
PaneHeaderAction::PaneHeaderDropped {
origin,
drop_location,
visual_tab_order,
} => {
match drop_location {
PaneDragDropLocation::TabBar(_) => {
self.is_visible_in_pane_group = true;
ctx.emit(Event::DroppedOnTabBar { origin: *origin })
ctx.emit(Event::DroppedOnTabBar {
origin: *origin,
visual_tab_order: visual_tab_order.clone(),
})
}
PaneDragDropLocation::PaneGroup(_) => {
ctx.emit(Event::PaneDroppedWithinPaneGroup)
Expand Down Expand Up @@ -1093,6 +1097,7 @@ pub fn render_pane_header_draggable<P: BackingView>(
>::PaneHeaderDropped {
origin: ActionOrigin::Pane,
drop_location: PaneDragDropLocation::TabBar(data.tab_bar_location),
visual_tab_order: None,
})
} else if let Some(data) = data.and_then(|data| {
data.as_any()
Expand All @@ -1104,6 +1109,7 @@ pub fn render_pane_header_draggable<P: BackingView>(
>::PaneHeaderDropped {
origin: ActionOrigin::Pane,
drop_location: PaneDragDropLocation::TabBar(data.tab_bar_location),
visual_tab_order: data.visual_tab_order.clone(),
})
} else if let Some(data) =
data.and_then(|data| data.as_any().downcast_ref::<PaneDropTargetData>())
Expand All @@ -1114,6 +1120,7 @@ pub fn render_pane_header_draggable<P: BackingView>(
>::PaneHeaderDropped {
origin: ActionOrigin::Pane,
drop_location: PaneDragDropLocation::PaneGroup(data.id),
visual_tab_order: None,
})
} else {
ctx.dispatch_typed_action(PaneHeaderAction::<
Expand All @@ -1122,6 +1129,7 @@ pub fn render_pane_header_draggable<P: BackingView>(
>::PaneHeaderDropped {
origin: ActionOrigin::Pane,
drop_location: PaneDragDropLocation::Other,
visual_tab_order: None,
})
}
})
Expand Down
11 changes: 9 additions & 2 deletions app/src/pane_group/pane/view/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ pub enum PaneViewEvent {
},
DroppedOnTabBar {
origin: ActionOrigin,
visual_tab_order: Option<Vec<usize>>,
},
DraggedOntoTabBar {
origin: ActionOrigin,
Expand Down Expand Up @@ -301,13 +302,19 @@ impl<P: BackingView> PaneView<P> {
self.is_being_dragged = false;
ctx.notify();
}
header::Event::DroppedOnTabBar { origin } => {
header::Event::DroppedOnTabBar {
origin,
visual_tab_order,
} => {
// If we're handling a drop event for a workspace pane, we want to get rid of the neutral background that obscures it.
if matches!(origin, ActionOrigin::Pane) {
self.is_being_dragged = false;
}

ctx.emit(PaneViewEvent::DroppedOnTabBar { origin: *origin });
ctx.emit(PaneViewEvent::DroppedOnTabBar {
origin: *origin,
visual_tab_order: visual_tab_order.clone(),
});
ctx.notify();
}
header::Event::DraggedOverTabBar {
Expand Down
1 change: 1 addition & 0 deletions app/src/tab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1662,6 +1662,7 @@ impl UiComponent for TabComponent<'_> {
ctx.dispatch_typed_action(WorkspaceAction::DragTab {
tab_index,
tab_position: rect,
vertical_context: None,
});
})
.on_drop(|ctx, _, _, _| ctx.dispatch_typed_action(WorkspaceAction::DropTab));
Expand Down
12 changes: 12 additions & 0 deletions app/src/workspace/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ pub enum TabContextMenuAnchor {
VerticalTabsKebab,
}

#[derive(Clone, Debug)]
pub struct VerticalTabDragContext {
pub visual_above_index: Option<usize>,
pub visual_below_index: Option<usize>,
pub current_group_indices: Vec<usize>,
pub visual_above_group_indices: Option<Vec<usize>>,
pub visual_below_group_indices: Option<Vec<usize>>,
}

#[derive(Debug, Clone, Copy)]
pub enum VerticalTabsPaneContextMenuTarget {
ClickedPane(PaneViewLocator),
Expand Down Expand Up @@ -245,6 +254,7 @@ pub enum WorkspaceAction {
DragTab {
tab_index: usize,
tab_position: RectF,
vertical_context: Option<VerticalTabDragContext>,
},
HandoffPendingTransfer {
target_window_id: WindowId,
Expand Down Expand Up @@ -280,6 +290,7 @@ pub enum WorkspaceAction {
SetVerticalTabsCompactSubtitle(VerticalTabsCompactSubtitle),
ToggleVerticalTabsShowPrLink,
ToggleVerticalTabsShowDiffStats,
ToggleVerticalTabsGroupByProject,
ToggleVerticalTabsShowDetailsOnHover,
/// Closes the focused panel. This happens as an explicit action from the user.
ClosePanel,
Expand Down Expand Up @@ -845,6 +856,7 @@ impl WorkspaceAction {
| SetVerticalTabsCompactSubtitle(_)
| ToggleVerticalTabsShowPrLink
| ToggleVerticalTabsShowDiffStats
| ToggleVerticalTabsGroupByProject
| ToggleVerticalTabsShowDetailsOnHover
| ToggleWelcomeTips
| CopyTextToClipboard(_)
Expand Down
3 changes: 2 additions & 1 deletion app/src/workspace/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1533,10 +1533,11 @@ pub struct TabBarDropTargetData {
pub tab_bar_location: TabBarLocation,
}

#[derive(PartialEq, Copy, Clone, Debug)]
#[derive(PartialEq, Clone, Debug)]
pub struct VerticalTabsPaneDropTargetData {
pub tab_bar_location: TabBarLocation,
pub tab_hover_index: TabBarHoverIndex,
pub visual_tab_order: Option<Vec<usize>>,
}

#[derive(PartialEq, Copy, Clone, Debug, Serialize, Deserialize)]
Expand Down
9 changes: 9 additions & 0 deletions app/src/workspace/tab_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,15 @@ define_settings_group!(TabSettings, settings: [
vertical_tabs_view_mode: VerticalTabsViewMode,
vertical_tabs_primary_info: VerticalTabsPrimaryInfo,
vertical_tabs_compact_subtitle: VerticalTabsCompactSubtitle,
vertical_tabs_group_by_project: VerticalTabsGroupByProject {
type: bool,
default: false,
supported_platforms: SupportedPlatforms::ALL,
sync_to_cloud: SyncToCloud::Globally(RespectUserSyncSetting::Yes),
private: false,
toml_path: "appearance.vertical_tabs.group_by_project",
description: "Group vertical tabs by project / git repo root.",
},
vertical_tabs_show_pr_link: VerticalTabsShowPrLink {
type: bool,
default: true,
Expand Down
Loading