-
-
Notifications
You must be signed in to change notification settings - Fork 833
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ActivateLastTab command #610
Conversation
I'd like to suggest |
@bew great point. It should have occurred to me when I reminded myself of how tmux did it :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this!
Some suggestions inline!
|
||
Activate the last active tab index. If there is none, it will do | ||
nothing. If the tabs get moved around, it will move to the last | ||
tab index rather than the last tab itself. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is that the desired behavior, or just simple to implement behavior?
If desired, then I'd suggest adding a brief example of what that means if the user reorganizes.
However, I think it isn't too much extra complexity to switch to the prior tab using its tabid with the inline suggestions!
mux/src/window.rs
Outdated
@@ -10,6 +10,7 @@ pub struct Window { | |||
id: WindowId, | |||
tabs: Vec<Rc<Tab>>, | |||
active: usize, | |||
last_active: Option<usize>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
last_active: Option<usize>, | |
last_active: Option<TabId>, |
mux/src/window.rs
Outdated
pub fn set_active(&mut self, idx: usize) { | ||
assert!(idx < self.tabs.len()); | ||
self.invalidated = true; | ||
self.last_active = Some(self.active); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.last_active = Some(self.active); | |
self.last_active = self.get_by_idx(self.active).map(|tab| tab.tab_id()); |
mux/src/window.rs
Outdated
@@ -124,9 +126,15 @@ impl Window { | |||
self.active | |||
} | |||
|
|||
#[inline] | |||
pub fn get_last_active_idx(&self) -> Option<usize> { | |||
self.last_active |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.last_active | |
self.last_active.map(|tab_id| self.idx_by_id(tab_id)) |
The issue is that move_tab removes and reinserts, so set_active gets called multiple times. Plus if you activate the same tab twice, it'll be its own "last_active." I'll see if I can figure out a way to get the ideal behavior that's not overly gross though. |
This replicates `last-window` in tmux. To pull this off, I deliberately store the last tab whenever I'm activating a new one or spawning a new one. I had to do this explicitly rather than hooking set_active, because we end up setting the active tab briefly for some common operations like moving a tab.
Thanks for this! I tweaked it a little because it felt like I could easily forget to save the tab if I changed some code later, and I found a single omission in the Tab Navigator. Thanks again! |
This replicates
last-window
in tmux. To pull this off, Ideliberately store the last tab whenever I'm activating a new one or
spawning a new one. I had to do this explicitly rather than hooking
set_active, because we end up setting the active tab briefly for some
common operations like moving a tab.