pane: Add functional clone on drop with control
modifier (#29921)
Release Notes: - Added a way to split and clone tab on with alt (macOS) / ctrl-mouse drop
This commit is contained in:
parent
2e62f16149
commit
2a973109d4
1 changed files with 21 additions and 1 deletions
|
@ -2833,6 +2833,9 @@ impl Pane {
|
|||
}
|
||||
}
|
||||
|
||||
let is_clone = cfg!(target_os = "macos") && window.modifiers().alt
|
||||
|| cfg!(not(target_os = "macos")) && window.modifiers().control;
|
||||
|
||||
let from_pane = dragged_tab.pane.clone();
|
||||
self.workspace
|
||||
.update(cx, |_, cx| {
|
||||
|
@ -2840,9 +2843,26 @@ impl Pane {
|
|||
if let Some(split_direction) = split_direction {
|
||||
to_pane = workspace.split_pane(to_pane, split_direction, window, cx);
|
||||
}
|
||||
let database_id = workspace.database_id();
|
||||
let old_ix = from_pane.read(cx).index_for_item_id(item_id);
|
||||
let old_len = to_pane.read(cx).items.len();
|
||||
move_item(&from_pane, &to_pane, item_id, ix, window, cx);
|
||||
if is_clone {
|
||||
let Some(item) = from_pane
|
||||
.read(cx)
|
||||
.items()
|
||||
.find(|item| item.item_id() == item_id)
|
||||
.map(|item| item.clone())
|
||||
else {
|
||||
return;
|
||||
};
|
||||
if let Some(item) = item.clone_on_split(database_id, window, cx) {
|
||||
to_pane.update(cx, |pane, cx| {
|
||||
pane.add_item(item, true, true, None, window, cx);
|
||||
})
|
||||
}
|
||||
} else {
|
||||
move_item(&from_pane, &to_pane, item_id, ix, window, cx);
|
||||
}
|
||||
if to_pane == from_pane {
|
||||
if let Some(old_index) = old_ix {
|
||||
to_pane.update(cx, |this, _| {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue