Repository navigation
Improve heavy workspace switch latency #4213
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -4398,9 +4398,16 @@ class TabManager: ObservableObject { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func selectWorkspace(_ workspace: Workspace) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| guard selectedTabId != workspace.id else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #if DEBUG | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| debugPrimeWorkspaceSwitchTrigger("select", to: workspace.id) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #if DEBUG | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| debugPrimeWorkspaceSwitchTrigger("select", to: workspace.id) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| activateWorkspaceCycleHotWindow() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| selectedTabId = workspace.id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -5454,14 +5461,24 @@ class TabManager: ObservableObject { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func selectTab(at index: Int) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| guard index >= 0 && index < tabs.count else { return } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let tabId = tabs[index].id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| guard selectedTabId != tabId else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #if DEBUG | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| debugPrimeWorkspaceSwitchTrigger("select_index", to: tabId) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #if DEBUG | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| debugPrimeWorkspaceSwitchTrigger("select_index", to: tabs[index].id) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| debugPrimeWorkspaceSwitchTrigger("select_index", to: tabId) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| selectedTabId = tabs[index].id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| activateWorkspaceCycleHotWindow() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| selectedTabId = tabId | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
5462
to
5476
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func selectLastTab() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| guard let lastTab = tabs.last else { return } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| guard selectedTabId != lastTab.id else { return } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| activateWorkspaceCycleHotWindow() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| selectedTabId = lastTab.id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||


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.
debugPrimeWorkspaceSwitchTriggercall appears in both the early-return branch and the fall-through branch with identical arguments. The function already guards onselectedTabId != targetinternally — calling it once, before the guard, produces the same effect in both paths and removes the duplication. As written, a future reader has to know the internal logic ofdebugPrimeWorkspaceSwitchTriggerto confirm the two calls aren't accidentally doing different things.