Skip to content

Commit

Permalink
fix: defer entering tui until needed
Browse files Browse the repository at this point in the history
  • Loading branch information
vinnymeller committed Jan 22, 2025
1 parent 420b47b commit e9ffe73
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ before running this command again.",

pub fn handle_existing_session_selection(args: &Arguments, tui: &mut Tui) -> Result<()> {
let existing_sessions = get_tmux_sessions()?;
tui.enter()?;
let session_name = match Picker::new(
&existing_sessions,
"Select an existing session to attach to: ".into(),
Expand All @@ -159,6 +160,7 @@ pub fn handle_existing_session_selection(args: &Arguments, tui: &mut Tui) -> Res

pub fn handle_group_session_selection(args: &Arguments, tui: &mut Tui) -> Result<()> {
let existing_sessions = get_tmux_sessions()?;
tui.enter()?;
let group_session_name = match Picker::new(
&existing_sessions,
"Select a session to group with: ".into(),
Expand Down Expand Up @@ -194,6 +196,7 @@ pub fn handle_workspace_selection(args: &Arguments, tui: &mut Tui) -> Result<()>
find_workspaces_in_dir(dir, &config, injector.clone())
}
});
tui.enter()?;
match picker.get_selection(tui)? {
PickerSelection::None => anyhow::bail!("No workspace selected"),
PickerSelection::Selection(s) => (s, false),
Expand Down
3 changes: 1 addition & 2 deletions src/ui/tui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ impl Tui {
let backend = CrosstermBackend::new(std::io::stderr());
let terminal = Terminal::new(backend)?;
let events = EventHandler::new(Duration::from_millis(15));
let mut tui = Self::new(terminal, events);
tui.enter()?;
let tui = Self::new(terminal, events);
Ok(tui)
}

Expand Down

0 comments on commit e9ffe73

Please sign in to comment.