Skip to content

Commit 13b45c5

Browse files
committed
Code review fixes
1 parent 8eb01b2 commit 13b45c5

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

editor/src/messages/portfolio/portfolio_message_handler.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,12 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageContext<'_>> for Portfolio
476476
return;
477477
}
478478

479+
// Validate that the target group exists before modifying the source
480+
if self.workspace_panel_layout.panel_group(target_group).is_none() {
481+
log::error!("Target panel group {target_group:?} not found");
482+
return;
483+
}
484+
479485
// Destroy layouts for all moved tabs and the displaced target tab
480486
for &panel_type in &tabs {
481487
Self::destroy_panel_layouts(panel_type, responses);
@@ -493,9 +499,7 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageContext<'_>> for Portfolio
493499
// Insert all tabs into the target group, preserving which tab was active in the source
494500
if let Some(target) = self.workspace_panel_layout.panel_group_mut(target_group) {
495501
let index = insert_index.min(target.tabs.len());
496-
for (i, panel_type) in tabs.iter().enumerate() {
497-
target.tabs.insert(index + i, *panel_type);
498-
}
502+
target.tabs.splice(index..index, tabs.iter().copied());
499503
target.active_tab_index = index + source_active_tab_index.min(tabs.len().saturating_sub(1));
500504
}
501505

0 commit comments

Comments
 (0)