Skip to content
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

feat(macos/gtk): keybind for accessing the last active tab #1869

Closed
wants to merge 3 commits into from

Conversation

SkamDart
Copy link
Collaborator

Resolves #1844

Tested on both aarch64-darwin and x86_64-linux (NixOS)

@tristan957
Copy link
Collaborator

I might've missed it but it doesn't look like this takes into account when tabs are deleted, at least for GTK. Didn't look at macos

@SkamDart
Copy link
Collaborator Author

I might've missed it but it doesn't look like this takes into account when tabs are deleted, at least for GTK. Didn't look at macos

Yes, it currently behaves naively and possibly incorrectly by attempting to navigate to a pane that does not exist. Open to feedback here on the expected behavior.

@mitchellh
Copy link
Contributor

mitchellh commented Jun 23, 2024

Looks pretty good so far. I think the major issues that need to be worked out before I can merge:

  • macOS needs to handle multiple tab groups
  • macOS/GTK both need to handle tab being closed and made invalid

Otherwise the core plumbing all looks very good to me! I'm happy to take a look at this soon if you don't get to it.

@SkamDart
Copy link
Collaborator Author

Looks pretty good so far. I think the major issues that need to be worked out before I can merge:

  • macOS needs to handle multiple tab groups

For this one, I am happy to accept help in the form of commit(s) or links to relevant parts of the code. Alternatively, I can read through the source and figure it out independently; it will take a bit longer as I am learning Swift/Macos app dev.

  • macOS/GTK both need to handle tab being closed and made invalid

What behavior do you think is the most intuitive? The current active tab?

Otherwise the core plumbing all looks very good to me! I'm happy to take a look at this soon if you don't get to it.

Thank you and a bigger thank you to @kdrag0n for giving me a commit to cherry-pick.

@tristan957
Copy link
Collaborator

What behavior do you think is the most intuitive? The current active tab?

I think you probably need to maintain a stack where the length of the stack is the number of tabs. When a new tab is focused, find its old position in the the stack, and move it to the front. This would be similar to how tmux works.

I'm not sure what a tab group is on Mac, but you might just need to maintain a stack per tab group or a stack that can span tab groups.

@mitchellh
Copy link
Contributor

I'd be fine simplifying this logic so that the "last active tab" is only valid so long as that tab remains valid. Once you close it, your last active tab is gone so the key bind does nothing. I don't think we need a full "back/forward" or "undo/redo" style logic here.

kdrag0n and others added 3 commits July 3, 2024 16:00
KVO on tabGroup.selectedWindow works but I can't figure out how to
detect when the tabGroup changes, so the observer gets attached to the
wrong tabGroup

TODO: lastActiveTabIndex needs to be per-tab-group, not global, but I
can't figure out how to store per-tab-group or per-associated-window
state
@SkamDart SkamDart force-pushed the last-active-tab-keybind branch from a9187bb to 0d5067a Compare July 3, 2024 23:00
@SkamDart SkamDart closed this Aug 14, 2024
@jacksongoode
Copy link
Collaborator

What happened to this PR? Will it be revived?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: keybind to swap to last active tab
5 participants