Skip to content

Commit 7c2b454

Browse files
committed
fix: Focus existing tabs with their panel index
1 parent c5274c4 commit 7c2b454

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/state/app.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,19 @@ impl AppState {
257257
let opened_tab = self.get_tab_if_exists(&tab);
258258

259259
if let Some(tab_id) = opened_tab {
260+
// Retrieve the panel index of the existing tab
261+
let panel_index = self
262+
.panels
263+
.iter()
264+
.enumerate()
265+
.find_map(|(panel_index, panel)| {
266+
if panel.tabs.contains(&tab_id) {
267+
Some(panel_index)
268+
} else {
269+
None
270+
}
271+
})
272+
.unwrap();
260273
// Focus the already open tab with the same content id
261274
self.focused_panel = panel_index;
262275
self.focus_tab(panel_index, Some(tab_id));

0 commit comments

Comments
 (0)