From 66ea0d5915d453771d5d59dc5d93a8278f7cd9cb Mon Sep 17 00:00:00 2001 From: Erik Kundt Date: Mon, 29 Dec 2025 12:00:26 +0100 Subject: [PATCH] issue/list: Allow editing comments --- bin/commands/issue.rs | 37 ++++++++++++++++++++++++++++++------ bin/commands/issue/common.rs | 2 ++ bin/commands/issue/list.rs | 19 ++++++++++++++++-- 3 files changed, 50 insertions(+), 8 deletions(-) diff --git a/bin/commands/issue.rs b/bin/commands/issue.rs index e4f9194d..7c1a499b 100644 --- a/bin/commands/issue.rs +++ b/bin/commands/issue.rs @@ -241,12 +241,37 @@ pub async fn run(options: Options, ctx: impl Context) -> anyhow::Result<()> { )?; break; } - IssueOperation::Edit { id } => { - terminal::run_rad( - Some("issue"), - &["edit".into(), id.to_string().into()], - Quiet::No, - )?; + IssueOperation::Edit { + id, + comment_id, + search, + } => { + state = PreviousState { + issue_id: Some(id), + comment_id, + search: Some(search), + }; + match comment_id { + Some(comment_id) => { + terminal::run_rad( + Some("issue"), + &[ + "comment".into(), + id.to_string().into(), + "--edit".into(), + comment_id.to_string().into(), + ], + Quiet::No, + )?; + } + _ => { + terminal::run_rad( + Some("issue"), + &["edit".into(), id.to_string().into()], + Quiet::No, + )?; + } + } } IssueOperation::Solve { id } => { terminal::run_rad( diff --git a/bin/commands/issue/common.rs b/bin/commands/issue/common.rs index 6e1083ba..eaa2388d 100644 --- a/bin/commands/issue/common.rs +++ b/bin/commands/issue/common.rs @@ -8,6 +8,8 @@ use radicle::{cob::thread::CommentId, issue::IssueId}; pub enum IssueOperation { Edit { id: IssueId, + comment_id: Option, + search: String, }, Show { id: IssueId, diff --git a/bin/commands/issue/list.rs b/bin/commands/issue/list.rs index 06e770dc..9346cbae 100644 --- a/bin/commands/issue/list.rs +++ b/bin/commands/issue/list.rs @@ -247,6 +247,7 @@ impl TryFrom<(&Context, &TerminalInfo)> for State { #[derive(Clone, Debug)] pub enum RequestedIssueOperation { Edit, + EditComment, Show, Reply, Solve, @@ -300,7 +301,18 @@ impl store::Update for State { issue.map(|issue| IssueOperation::Show { id: issue.id }) } Some(RequestedIssueOperation::Edit) => { - issue.map(|issue| IssueOperation::Edit { id: issue.id }) + issue.map(|issue| IssueOperation::Edit { + id: issue.id, + comment_id: None, + search: self.browser.read_search(), + }) + } + Some(RequestedIssueOperation::EditComment) => { + issue.map(|issue| IssueOperation::Edit { + id: issue.id, + comment_id: comment.map(|c| c.id), + search: self.browser.read_search(), + }) } Some(RequestedIssueOperation::Solve) => { issue.map(|issue| IssueOperation::Solve { id: issue.id }) @@ -455,7 +467,7 @@ fn browser_page(channel: &Channel) -> Widget { } shortcuts } - _ => [("c", "reply")].to_vec(), + _ => [("e", "edit"), ("c", "reply")].to_vec(), } }; let global_shortcuts = vec![("p", "toggle preview"), ("?", "help")]; @@ -620,6 +632,9 @@ fn comment_tree(channel: &Channel) -> Widget { Event::Key(Key::Char('c')) => Some(Message::Exit { operation: Some(RequestedIssueOperation::Reply), }), + Event::Key(Key::Char('e')) => Some(Message::Exit { + operation: Some(RequestedIssueOperation::EditComment), + }), _ => Some(Message::SelectComment { selected: s.and_then(|s| { s.unwrap_tree()