Skip to content

Commit cfd78d5

Browse files
committed
Focus the tab together with opening the panel
This removes the flicker. It may make the tab switching feel less snappy because we are deliberately waiting a bit but both the tab and the hold version feel much better this way.
1 parent 0fcf91e commit cfd78d5

2 files changed

Lines changed: 14 additions & 10 deletions

File tree

plugin/commands.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,7 @@
44
from .ctrl_release import is_available
55
from .history import current_group_selection_state, sync_selection_history
66
from .mru import collect_entries
7-
from .session import (
8-
cancel_session,
9-
preview_entry,
10-
reopen_panel_at_index,
11-
schedule_panel,
12-
show_panel,
13-
)
7+
from .session import cancel_session, reopen_panel_at_index, schedule_panel, show_panel
148
from .state import get_state
159

1610

@@ -33,7 +27,6 @@ def run(self, *, forward=True, selected_index: int = 1) -> None:
3327
state.session_pending_token += 1
3428
state.session_active = True
3529
state.session_selected_index = selected_index
36-
preview_entry(window, state)
3730
show_panel(window, state)
3831
return
3932

@@ -49,7 +42,6 @@ def run(self, *, forward=True, selected_index: int = 1) -> None:
4942
state.session_group = active_group
5043
state.session_entries = entries
5144
state.session_selected_index = selected_index
52-
preview_entry(window, state)
5345
schedule_panel(window, state, token=state.session_pending_token)
5446

5547

plugin/session.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def on_release() -> None:
1616
if state.session_active:
1717
_commit_session(window, state)
1818
elif state.session_pending:
19-
state.clear_session()
19+
_commit_pending_session(window, state)
2020

2121
state.ctrl_release_poller = CtrlReleasePoller(on_release, 25)
2222
state.ctrl_release_poller.start()
@@ -77,6 +77,18 @@ def preview_entry(window, state: TabStackWindowState) -> None:
7777
apply_group_selection(window, entry.selection, state.session_group)
7878

7979

80+
def _commit_pending_session(window, state) -> None:
81+
entries = state.session_entries
82+
if not entries:
83+
state.clear_session()
84+
return
85+
86+
index = clamp_index(state.session_selected_index, len(entries))
87+
selection = entries[index].selection
88+
apply_group_selection(window, selection, state.session_group)
89+
state.clear_session()
90+
91+
8092
def _commit_session(window, state) -> None:
8193
if not state.session_active:
8294
return

0 commit comments

Comments
 (0)