Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/plugins/todo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,20 @@ impl TodoPlugin {
}) {
ParseArgsResult::Parsed((text, priority, tags)) => {
let tag_str = tags.join(",");
let mut label_suffix_parts: Vec<String> = Vec::new();
if !tags.is_empty() {
label_suffix_parts.push(format!("Tag: {}", tags.join(", ")));
}
if priority > 0 {
label_suffix_parts.push(format!("priority: {priority}"));
}
let label = if label_suffix_parts.is_empty() {
format!("Add todo {text}")
} else {
format!("Add todo {text} {}", label_suffix_parts.join("; "))
};
return vec![Action {
label: format!("Add todo {text}"),
label,
desc: "Todo".into(),
action: format!("todo:add:{text}|{priority}|{tag_str}"),
args: None,
Expand Down
3 changes: 3 additions & 0 deletions tests/todo_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ fn search_add_returns_action() {
let results = plugin.search("todo add task ");
assert_eq!(results.len(), 1);
assert_eq!(results[0].action, "todo:add:task|0|");
assert_eq!(results[0].label, "Add todo task");
}

#[test]
Expand All @@ -48,6 +49,7 @@ fn search_add_with_priority_and_tags() {
let results = plugin.search("todo add task p=3 #a #b");
assert_eq!(results.len(), 1);
assert_eq!(results[0].action, "todo:add:task|3|a,b");
assert_eq!(results[0].label, "Add todo task Tag: a, b; priority: 3");
}

#[test]
Expand All @@ -57,6 +59,7 @@ fn search_add_with_at_tags() {
let results = plugin.search("todo add task @a @b");
assert_eq!(results.len(), 1);
assert_eq!(results[0].action, "todo:add:task|0|a,b");
assert_eq!(results[0].label, "Add todo task Tag: a, b");
}

#[test]
Expand Down