feat(ux): print current query to stdout on Enter if no entry is selected (#151)

Fixes #49
This commit is contained in:
Alex Pasmantier 2024-12-28 16:36:30 +01:00 committed by GitHub
parent 12fdf94e5d
commit c3b8c68d1b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 2 deletions

View File

@ -45,6 +45,7 @@ pub struct App {
#[derive(Debug)]
pub enum ActionOutcome {
Entry(Entry),
Input(String),
Passthrough(Entry, String),
None,
}
@ -63,6 +64,10 @@ impl From<ActionOutcome> for AppOutput {
selected_entry: Some(entry),
passthrough: None,
},
ActionOutcome::Input(input) => Self {
selected_entry: None,
passthrough: Some(input),
},
ActionOutcome::Passthrough(entry, key) => Self {
selected_entry: Some(entry),
passthrough: Some(key),
@ -261,7 +266,9 @@ impl App {
{
return Ok(ActionOutcome::Entry(entry));
}
return Ok(ActionOutcome::None);
return Ok(ActionOutcome::Input(
self.television.lock().await.current_pattern.clone(),
));
}
Action::SelectPassthrough(passthrough) => {
self.should_quit = true;

View File

@ -38,7 +38,7 @@ pub struct Television {
pub(crate) channel: TelevisionChannel,
pub(crate) remote_control: TelevisionChannel,
pub mode: Mode,
current_pattern: String,
pub current_pattern: String,
pub(crate) results_picker: Picker,
pub(crate) rc_picker: Picker,
results_area_height: u32,
@ -358,6 +358,11 @@ impl Television {
self.change_channel(new_channel);
}
}
} else {
self.action_tx
.as_ref()
.unwrap()
.send(Action::SelectAndExit)?;
}
}
Action::CopyEntryToClipboard => {