Add keybinding to swap pane items (#15583)
- Rearrange tabs (left: `ctrl-shift-pageup`, right: `ctrl-shift-pagedown`) like Chrome Co-authored-by: Peter Tripp <peter@zed.dev>
This commit is contained in:
parent
adbe973f02
commit
1b36c62188
4 changed files with 70 additions and 40 deletions
|
@ -245,6 +245,8 @@
|
||||||
"bindings": {
|
"bindings": {
|
||||||
"ctrl-pageup": "pane::ActivatePrevItem",
|
"ctrl-pageup": "pane::ActivatePrevItem",
|
||||||
"ctrl-pagedown": "pane::ActivateNextItem",
|
"ctrl-pagedown": "pane::ActivateNextItem",
|
||||||
|
"ctrl-shift-pageup": "pane::SwapItemLeft",
|
||||||
|
"ctrl-shift-pagedown": "pane::SwapItemRight",
|
||||||
"ctrl-w": "pane::CloseActiveItem",
|
"ctrl-w": "pane::CloseActiveItem",
|
||||||
"ctrl-f4": "pane::CloseActiveItem",
|
"ctrl-f4": "pane::CloseActiveItem",
|
||||||
"alt-ctrl-t": "pane::CloseInactiveItems",
|
"alt-ctrl-t": "pane::CloseInactiveItems",
|
||||||
|
|
|
@ -285,6 +285,8 @@
|
||||||
"cmd-}": "pane::ActivateNextItem",
|
"cmd-}": "pane::ActivateNextItem",
|
||||||
"alt-cmd-left": "pane::ActivatePrevItem",
|
"alt-cmd-left": "pane::ActivatePrevItem",
|
||||||
"alt-cmd-right": "pane::ActivateNextItem",
|
"alt-cmd-right": "pane::ActivateNextItem",
|
||||||
|
"ctrl-shift-pageup": "pane::SwapItemLeft",
|
||||||
|
"ctrl-shift-pagedown": "pane::SwapItemRight",
|
||||||
"cmd-w": "pane::CloseActiveItem",
|
"cmd-w": "pane::CloseActiveItem",
|
||||||
"alt-cmd-t": "pane::CloseInactiveItems",
|
"alt-cmd-t": "pane::CloseInactiveItems",
|
||||||
"ctrl-alt-cmd-w": "workspace::CloseInactiveTabsAndPanes",
|
"ctrl-alt-cmd-w": "workspace::CloseInactiveTabsAndPanes",
|
||||||
|
|
|
@ -158,6 +158,8 @@ actions!(
|
||||||
SplitDown,
|
SplitDown,
|
||||||
SplitHorizontal,
|
SplitHorizontal,
|
||||||
SplitVertical,
|
SplitVertical,
|
||||||
|
SwapItemLeft,
|
||||||
|
SwapItemRight,
|
||||||
TogglePreviewTab,
|
TogglePreviewTab,
|
||||||
TogglePinTab,
|
TogglePinTab,
|
||||||
]
|
]
|
||||||
|
@ -1054,6 +1056,26 @@ impl Pane {
|
||||||
self.activate_item(index, activate_pane, activate_pane, cx);
|
self.activate_item(index, activate_pane, activate_pane, cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn swap_item_left(&mut self, cx: &mut ViewContext<Self>) {
|
||||||
|
let index = self.active_item_index;
|
||||||
|
if index == 0 {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.items.swap(index, index - 1);
|
||||||
|
self.activate_item(index - 1, true, true, cx);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn swap_item_right(&mut self, cx: &mut ViewContext<Self>) {
|
||||||
|
let index = self.active_item_index;
|
||||||
|
if index + 1 == self.items.len() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.items.swap(index, index + 1);
|
||||||
|
self.activate_item(index + 1, true, true, cx);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn close_active_item(
|
pub fn close_active_item(
|
||||||
&mut self,
|
&mut self,
|
||||||
action: &CloseActiveItem,
|
action: &CloseActiveItem,
|
||||||
|
@ -2574,6 +2596,8 @@ impl Render for Pane {
|
||||||
.on_action(cx.listener(|pane: &mut Pane, _: &ActivateNextItem, cx| {
|
.on_action(cx.listener(|pane: &mut Pane, _: &ActivateNextItem, cx| {
|
||||||
pane.activate_next_item(true, cx);
|
pane.activate_next_item(true, cx);
|
||||||
}))
|
}))
|
||||||
|
.on_action(cx.listener(|pane, _: &SwapItemLeft, cx| pane.swap_item_left(cx)))
|
||||||
|
.on_action(cx.listener(|pane, _: &SwapItemRight, cx| pane.swap_item_right(cx)))
|
||||||
.on_action(cx.listener(|pane, action, cx| {
|
.on_action(cx.listener(|pane, action, cx| {
|
||||||
pane.toggle_pin_tab(action, cx);
|
pane.toggle_pin_tab(action, cx);
|
||||||
}))
|
}))
|
||||||
|
|
|
@ -406,7 +406,7 @@ TBD: Add Column with Linux shortcuts
|
||||||
#### Pane
|
#### Pane
|
||||||
|
|
||||||
| **Command** | **Target** | **Default Shortcut** |
|
| **Command** | **Target** | **Default Shortcut** |
|
||||||
| ----------------------------- | -------------- | ----------------------- |
|
| ----------------------------- | -------------- | ----------------------------- |
|
||||||
| Activate item 1 | Pane | `Control + 1` |
|
| Activate item 1 | Pane | `Control + 1` |
|
||||||
| Activate item 2 | Pane | `Control + 2` |
|
| Activate item 2 | Pane | `Control + 2` |
|
||||||
| Activate item 3 | Pane | `Control + 3` |
|
| Activate item 3 | Pane | `Control + 3` |
|
||||||
|
@ -421,6 +421,8 @@ TBD: Add Column with Linux shortcuts
|
||||||
| Activate next item | Pane | `⌘ + }` |
|
| Activate next item | Pane | `⌘ + }` |
|
||||||
| Activate prev item | Pane | `Alt + ⌘ + Left` |
|
| Activate prev item | Pane | `Alt + ⌘ + Left` |
|
||||||
| Activate prev item | Pane | `⌘ + {` |
|
| Activate prev item | Pane | `⌘ + {` |
|
||||||
|
| Swap item to left | Pane | `Control + Shift + Page Up` |
|
||||||
|
| Swap item to right | Pane | `Control + Shift + Page Down` |
|
||||||
| Close active item | Pane | `⌘ + W` |
|
| Close active item | Pane | `⌘ + W` |
|
||||||
| Close all items | Pane | `⌘ + K, ⌘ + W` |
|
| Close all items | Pane | `⌘ + K, ⌘ + W` |
|
||||||
| Close clean items | Pane | `⌘ + K, U` |
|
| Close clean items | Pane | `⌘ + K, U` |
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue