tweak ActivateLastTab and add a changelog entry for it
refs: https://github.com/wez/wezterm/pull/610
This commit is contained in:
1 parent
ee4b4b598c
commit
4a3e0615f5
6 files changed
+24
-11
No files matched your search
@@ -35,6 +35,7 @@ brief notes about them may accumulate here.
|
||||
* Fixed: Windows: we now compile libssh2 against openssl on all platforms to improve overall key and crypto algorithm support
|
||||
* Fixed: spawning a new tab via the launcher menu failed because it used the pretty printed multiplexer domain label rather than the multiplexer domain name.
|
||||
* Fixed: macOS: middle mouse button wasn't recognized. Thanks to [@guswynn](https://github.com/guswynn)! [#599](https://github.com/wez/wezterm/pull/599)
|
||||
* New: added [ActivateLastTab](config/lua/keyassignment/ActivateLastTab.md) key assignment for jumping back to a previously active tab. Thanks to [@alexgartrell](https://github.com/alexgartrell) [#610](https://github.com/wez/wezterm/pull/610)
|
||||
|
||||
### 20210314-114017-04b7cedd
|
||||
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
# ActivateLastTab
|
||||
|
||||
*Since: nightly builds only*
|
||||
|
||||
Activate the last active tab. If there is none, it will do nothing.
|
||||
|
||||
|
||||
```lua
|
||||
return {
|
||||
leader = { key="a", mods="CTRL" },
|
||||
keys = {
|
||||
-- CTRL-a, followed by CTRL-o will switch back to the last active tab
|
||||
{key="o", mods="LEADER|CTRL", action="ActivateLastTab"},
|
||||
}
|
||||
}
|
||||
|
||||
+15
-2
@@ -103,7 +103,7 @@ impl Window {
|
||||
self.tabs.remove(idx);
|
||||
let len = self.tabs.len();
|
||||
if len > 0 && self.active == idx && idx >= len {
|
||||
self.set_active(len - 1);
|
||||
self.set_active_without_saving(len - 1);
|
||||
}
|
||||
true
|
||||
} else {
|
||||
@@ -139,7 +139,20 @@ impl Window {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_active(&mut self, idx: usize) {
|
||||
/// If `idx` is different from the current active tab,
|
||||
/// save the current tabid and then make `idx` the active
|
||||
/// tab position.
|
||||
pub fn save_and_then_set_active(&mut self, idx: usize) {
|
||||
if idx == self.get_active_idx() {
|
||||
return;
|
||||
}
|
||||
self.save_last_active();
|
||||
self.set_active_without_saving(idx);
|
||||
}
|
||||
|
||||
/// Make `idx` the active tab position.
|
||||
/// The saved tab id is not changed.
|
||||
pub fn set_active_without_saving(&mut self, idx: usize) {
|
||||
assert!(idx < self.tabs.len());
|
||||
self.invalidated = true;
|
||||
self.active = idx;
|
||||
|
||||
@@ -80,7 +80,7 @@ pub fn tab_navigator(
|
||||
.get_window_mut(mux_window_id)
|
||||
.ok_or_else(|| anyhow!("no such window"))?;
|
||||
|
||||
window.set_active(idx);
|
||||
window.save_and_then_set_active(idx);
|
||||
anyhow::Result::<()>::Ok(())
|
||||
})
|
||||
.detach();
|
||||
|
||||
@@ -1098,10 +1098,7 @@ impl TermWindow {
|
||||
};
|
||||
|
||||
if tab_idx < max {
|
||||
if tab_idx != window.get_active_idx() {
|
||||
window.save_last_active();
|
||||
}
|
||||
window.set_active(tab_idx);
|
||||
window.save_and_then_set_active(tab_idx);
|
||||
|
||||
drop(window);
|
||||
|
||||
@@ -1160,7 +1157,7 @@ impl TermWindow {
|
||||
|
||||
let tab_inst = window.remove_by_idx(active);
|
||||
window.insert(tab_idx, &tab_inst);
|
||||
window.set_active(tab_idx);
|
||||
window.set_active_without_saving(tab_idx);
|
||||
|
||||
drop(window);
|
||||
self.update_title();
|
||||
|
||||
@@ -186,9 +186,8 @@ impl super::TermWindow {
|
||||
let mut window = mux
|
||||
.get_window_mut(target_window_id)
|
||||
.ok_or_else(|| anyhow!("no such window!?"))?;
|
||||
window.save_last_active();
|
||||
if let Some(idx) = window.idx_by_id(tab_id) {
|
||||
window.set_active(idx);
|
||||
window.save_and_then_set_active(idx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user