Skip to content

Commit b770c70

Browse files
committed
Code review
1 parent 919fe1e commit b770c70

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

editor/src/messages/portfolio/portfolio_message_handler.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,12 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageContext<'_>> for Portfolio
472472
let Some(source_state) = self.workspace_panel_layout.panel_group(source_group) else { return };
473473
let Some(panel_type) = source_state.active_panel_type() else { return };
474474

475+
// Validate that the target group exists before modifying the source
476+
if self.workspace_panel_layout.panel_group(target_group).is_none() {
477+
log::error!("Target panel group {target_group:?} not found");
478+
return;
479+
}
480+
475481
// Destroy layouts for the moved panel (so backend and frontend start in sync when it remounts)
476482
// and for the panel that was previously active in the target panel group (it will be displaced by the incoming tab)
477483
Self::destroy_panel_layouts(panel_type, responses);

editor/src/messages/portfolio/utility_types.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,9 @@ impl PanelLayoutSubdivision {
418418
// Remove empty panel groups
419419
children.retain(|child| !matches!(&child.subdivision, PanelLayoutSubdivision::PanelGroup { state, .. } if state.tabs.is_empty()));
420420

421+
// Remove empty splits (splits that lost all their children after pruning)
422+
children.retain(|child| !matches!(&child.subdivision, PanelLayoutSubdivision::Split { children } if children.is_empty()));
423+
421424
// If a split has exactly one child, replace this subdivision with that child's subdivision
422425
if children.len() == 1 {
423426
*self = children.remove(0).subdivision;
@@ -470,7 +473,7 @@ impl PanelLayoutSubdivision {
470473
}
471474
}
472475

473-
/// Remove a panel group by ID and prune the tree.
476+
/// Remove a panel group by ID from the tree. Does not prune.
474477
pub fn remove_group(&mut self, target_id: PanelGroupId) {
475478
if let PanelLayoutSubdivision::Split { children } = self {
476479
children.retain(|child| !matches!(&child.subdivision, PanelLayoutSubdivision::PanelGroup { id, .. } if *id == target_id));

frontend/src/components/window/PanelSubdivision.svelte

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,10 @@
8282
8383
const abortResize = () => {
8484
if (pointerCaptureId) gutter.releasePointerCapture(pointerCaptureId);
85+
pointerCaptureId = undefined;
8586
removeListeners();
8687
activeResizeCleanup = undefined;
8788
88-
pointerCaptureId = e.pointerId;
89-
gutter.setPointerCapture(pointerCaptureId);
90-
9189
if (gutterResizeRestore !== undefined) {
9290
sizeOverrides = { ...sizeOverrides, [nextIndex]: gutterResizeRestore[0], [prevIndex]: gutterResizeRestore[1] };
9391
gutterResizeRestore = undefined;

0 commit comments

Comments
 (0)