From ae40ca27a9edeb01c3df34f15709c4f38836c9a5 Mon Sep 17 00:00:00 2001 From: Erik Kundt Date: Thu, 8 Jan 2026 14:59:37 +0100 Subject: [PATCH] issue/list: Store state and fix issue pre-selection --- bin/commands/issue.rs | 21 ++++++++++++++++++--- bin/commands/issue/common.rs | 3 +++ bin/commands/issue/list.rs | 23 ++++++++++++++++------- 3 files changed, 37 insertions(+), 10 deletions(-) diff --git a/bin/commands/issue.rs b/bin/commands/issue.rs index 8806cbdb..054100ca 100644 --- a/bin/commands/issue.rs +++ b/bin/commands/issue.rs @@ -270,19 +270,34 @@ pub async fn run(options: Options, ctx: impl Context) -> anyhow::Result<()> { } } } - IssueOperation::Solve { id } => { + IssueOperation::Solve { id, search } => { + state = PreviousState { + issue_id: Some(id), + comment_id: None, + search: Some(search), + }; terminal::run_rad( Some("issue"), &["state".into(), id.to_string().into(), "--solved".into()], )?; } - IssueOperation::Close { id } => { + IssueOperation::Close { id, search } => { + state = PreviousState { + issue_id: Some(id), + comment_id: None, + search: Some(search), + }; terminal::run_rad( Some("issue"), &["state".into(), id.to_string().into(), "--closed".into()], )?; } - IssueOperation::Reopen { id } => { + IssueOperation::Reopen { id, search } => { + state = PreviousState { + issue_id: Some(id), + comment_id: None, + search: Some(search), + }; terminal::run_rad( Some("issue"), &["state".into(), id.to_string().into(), "--open".into()], diff --git a/bin/commands/issue/common.rs b/bin/commands/issue/common.rs index eaa2388d..9307536b 100644 --- a/bin/commands/issue/common.rs +++ b/bin/commands/issue/common.rs @@ -16,12 +16,15 @@ pub enum IssueOperation { }, Close { id: IssueId, + search: String, }, Solve { id: IssueId, + search: String, }, Reopen { id: IssueId, + search: String, }, Comment { id: IssueId, diff --git a/bin/commands/issue/list.rs b/bin/commands/issue/list.rs index 7cde8376..a208b641 100644 --- a/bin/commands/issue/list.rs +++ b/bin/commands/issue/list.rs @@ -295,17 +295,17 @@ impl TryFrom<(&Context, &TerminalInfo)> for App { .collect(); let browser = state::Browser { - issues: TableState::new( + issues: TableState::new(Some( context .issue - .map(|id| { + .and_then(|id| { issues .iter() .filter(|item| filter.matches(item)) .position(|item| item.id() == id) }) - .unwrap_or(issues.first().map(|_| 0)), - ), + .unwrap_or(0), + )), search: BufferedValue::new(TextEditState { text: search.read().clone(), cursor: search.read().len(), @@ -657,19 +657,28 @@ impl App { if ui.has_input(|key| key == Key::Char('s')) { ui.send_message(Message::Exit { - operation: Some(IssueOperation::Solve { id: issue.id }), + operation: Some(IssueOperation::Solve { + id: issue.id, + search: browser.search.read().text, + }), }); } if ui.has_input(|key| key == Key::Char('l')) { ui.send_message(Message::Exit { - operation: Some(IssueOperation::Close { id: issue.id }), + operation: Some(IssueOperation::Close { + id: issue.id, + search: browser.search.read().text, + }), }); } if ui.has_input(|key| key == Key::Char('o')) { ui.send_message(Message::Exit { - operation: Some(IssueOperation::Reopen { id: issue.id }), + operation: Some(IssueOperation::Reopen { + id: issue.id, + search: browser.search.read().text, + }), }); } }