2024-07-25 22:40:35 +03:00
|
|
|
use std::collections::{BTreeSet, HashMap};
|
2024-07-24 21:11:36 +03:00
|
|
|
use std::iter::once;
|
2024-07-19 01:15:11 +03:00
|
|
|
|
2024-07-25 00:26:29 +03:00
|
|
|
use nostr_sdk::{Event, EventBuilder, EventId, Keys, Kind, Tag};
|
2024-07-25 22:40:35 +03:00
|
|
|
use nostr_sdk::Tag::Hashtag;
|
2024-07-19 21:06:03 +03:00
|
|
|
|
2024-07-24 16:03:34 +03:00
|
|
|
use crate::{EventSender, TASK_KIND};
|
2024-07-19 21:06:03 +03:00
|
|
|
use crate::task::{State, Task};
|
|
|
|
|
2024-07-19 01:15:11 +03:00
|
|
|
type TaskMap = HashMap<EventId, Task>;
|
|
|
|
pub(crate) struct Tasks {
|
2024-07-19 09:35:03 +03:00
|
|
|
/// The Tasks
|
2024-07-24 21:11:36 +03:00
|
|
|
tasks: TaskMap,
|
2024-07-19 09:35:03 +03:00
|
|
|
/// The task properties currently visible
|
2024-07-19 01:15:11 +03:00
|
|
|
pub(crate) properties: Vec<String>,
|
2024-07-25 00:26:29 +03:00
|
|
|
/// Negative: Only Leaf nodes
|
|
|
|
/// Zero: Only Active node
|
|
|
|
/// Positive: Go down the respective level
|
|
|
|
pub(crate) depth: i8,
|
2024-07-24 21:11:36 +03:00
|
|
|
|
2024-07-25 22:40:35 +03:00
|
|
|
/// Currently active task
|
2024-07-19 01:15:11 +03:00
|
|
|
position: Option<EventId>,
|
2024-07-25 22:40:35 +03:00
|
|
|
/// Currently active tags
|
|
|
|
tags: BTreeSet<Tag>,
|
2024-07-19 09:35:03 +03:00
|
|
|
/// A filtered view of the current tasks
|
|
|
|
view: Vec<EventId>,
|
2024-07-24 21:11:36 +03:00
|
|
|
|
2024-07-25 10:55:29 +03:00
|
|
|
sender: EventSender,
|
2024-07-19 01:15:11 +03:00
|
|
|
}
|
|
|
|
|
2024-07-24 16:03:34 +03:00
|
|
|
impl Tasks {
|
|
|
|
pub(crate) fn from(sender: EventSender) -> Self {
|
2024-07-19 01:15:11 +03:00
|
|
|
Tasks {
|
|
|
|
tasks: Default::default(),
|
2024-07-24 16:03:34 +03:00
|
|
|
properties: vec!["id".into(), "name".into(), "state".into(), "ttime".into()],
|
2024-07-19 01:15:11 +03:00
|
|
|
position: None,
|
2024-07-19 09:35:03 +03:00
|
|
|
view: Default::default(),
|
2024-07-25 22:40:35 +03:00
|
|
|
tags: Default::default(),
|
2024-07-25 00:26:29 +03:00
|
|
|
depth: 1,
|
2024-07-25 10:55:29 +03:00
|
|
|
sender,
|
2024-07-19 01:15:11 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Tasks {
|
2024-07-25 22:10:01 +03:00
|
|
|
// Accessors
|
|
|
|
|
2024-07-19 01:15:11 +03:00
|
|
|
pub(crate) fn get_position(&self) -> Option<EventId> {
|
|
|
|
self.position
|
|
|
|
}
|
2024-07-19 21:06:03 +03:00
|
|
|
|
2024-07-19 09:44:12 +03:00
|
|
|
/// Total time this task and its subtasks have been active
|
|
|
|
fn total_time_tracked(&self, task: &EventId) -> u64 {
|
|
|
|
self.tasks.get(task).map_or(0, |t| {
|
2024-07-19 21:06:03 +03:00
|
|
|
t.time_tracked()
|
|
|
|
+ t.children
|
|
|
|
.iter()
|
|
|
|
.map(|e| self.total_time_tracked(e))
|
|
|
|
.sum::<u64>()
|
2024-07-19 09:44:12 +03:00
|
|
|
})
|
|
|
|
}
|
2024-07-19 21:06:03 +03:00
|
|
|
|
2024-07-25 22:10:01 +03:00
|
|
|
// Parents
|
|
|
|
|
|
|
|
pub(crate) fn parent(&self, id: Option<EventId>) -> Option<EventId> {
|
|
|
|
id.and_then(|id| self.tasks.get(&id))
|
|
|
|
.and_then(|t| t.parent_id())
|
|
|
|
}
|
|
|
|
|
|
|
|
pub(crate) fn taskpath(&self, id: Option<EventId>) -> String {
|
|
|
|
join_tasks(self.traverse_up_from(id))
|
2024-07-25 22:40:35 +03:00
|
|
|
+ &self
|
|
|
|
.tags
|
|
|
|
.iter()
|
|
|
|
.map(|t| format!(" #{}", t.content().unwrap()))
|
|
|
|
.collect::<Vec<String>>()
|
|
|
|
.join("")
|
2024-07-25 22:10:01 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
pub(crate) fn traverse_up_from(&self, id: Option<EventId>) -> ParentIterator {
|
|
|
|
ParentIterator {
|
|
|
|
tasks: &self.tasks,
|
|
|
|
current: id,
|
|
|
|
prev: None,
|
|
|
|
}
|
2024-07-19 09:35:03 +03:00
|
|
|
}
|
2024-07-25 10:55:29 +03:00
|
|
|
|
2024-07-25 22:10:01 +03:00
|
|
|
// Helpers
|
|
|
|
|
|
|
|
fn resolve_tasks<'a>(&self, iter: impl IntoIterator<Item = &'a EventId>) -> Vec<&Task> {
|
2024-07-25 00:26:29 +03:00
|
|
|
self.resolve_tasks_rec(iter, self.depth)
|
|
|
|
}
|
|
|
|
|
2024-07-25 10:55:29 +03:00
|
|
|
fn resolve_tasks_rec<'a>(
|
|
|
|
&self,
|
2024-07-25 22:10:01 +03:00
|
|
|
iter: impl IntoIterator<Item = &'a EventId>,
|
2024-07-25 10:55:29 +03:00
|
|
|
depth: i8,
|
|
|
|
) -> Vec<&Task> {
|
|
|
|
iter.into_iter()
|
|
|
|
.filter_map(|id| self.tasks.get(&id))
|
|
|
|
.flat_map(|task| {
|
|
|
|
let new_depth = depth - 1;
|
|
|
|
if new_depth < 0 {
|
|
|
|
let tasks = self
|
|
|
|
.resolve_tasks_rec(task.children.iter(), new_depth)
|
|
|
|
.into_iter()
|
|
|
|
.collect::<Vec<&Task>>();
|
|
|
|
if tasks.is_empty() {
|
|
|
|
vec![task]
|
|
|
|
} else {
|
|
|
|
tasks
|
|
|
|
}
|
|
|
|
} else if new_depth > 0 {
|
|
|
|
self.resolve_tasks_rec(task.children.iter(), new_depth)
|
|
|
|
.into_iter()
|
|
|
|
.chain(once(task))
|
|
|
|
.collect()
|
2024-07-25 00:26:29 +03:00
|
|
|
} else {
|
2024-07-25 10:55:29 +03:00
|
|
|
vec![task]
|
2024-07-25 00:26:29 +03:00
|
|
|
}
|
2024-07-25 10:55:29 +03:00
|
|
|
})
|
|
|
|
.collect()
|
2024-07-24 21:11:36 +03:00
|
|
|
}
|
2024-07-25 00:26:29 +03:00
|
|
|
|
2024-07-25 22:10:01 +03:00
|
|
|
pub(crate) fn referenced_tasks<F: Fn(&mut Task)>(&mut self, event: &Event, f: F) {
|
|
|
|
for tag in event.tags.iter() {
|
|
|
|
if let Tag::Event { event_id, .. } = tag {
|
|
|
|
self.tasks.get_mut(event_id).map(|t| f(t));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-07-19 09:35:03 +03:00
|
|
|
pub(crate) fn current_tasks(&self) -> Vec<&Task> {
|
2024-07-25 00:26:29 +03:00
|
|
|
if self.depth == 0 {
|
2024-07-25 10:55:29 +03:00
|
|
|
return self
|
|
|
|
.position
|
|
|
|
.and_then(|id| self.tasks.get(&id))
|
|
|
|
.into_iter()
|
|
|
|
.collect();
|
2024-07-25 00:26:29 +03:00
|
|
|
}
|
2024-07-24 21:11:36 +03:00
|
|
|
let res: Vec<&Task> = self.resolve_tasks(self.view.iter());
|
2024-07-19 09:35:03 +03:00
|
|
|
if res.len() > 0 {
|
|
|
|
return res;
|
|
|
|
}
|
2024-07-25 22:40:35 +03:00
|
|
|
let tasks = self.position.map_or_else(
|
2024-07-24 21:11:36 +03:00
|
|
|
|| {
|
2024-07-25 00:26:29 +03:00
|
|
|
if self.depth > 8 {
|
2024-07-24 21:11:36 +03:00
|
|
|
self.tasks.values().collect()
|
2024-07-25 00:26:29 +03:00
|
|
|
} else if self.depth == 1 {
|
2024-07-25 10:55:29 +03:00
|
|
|
self.tasks
|
|
|
|
.values()
|
|
|
|
.filter(|t| t.parent_id() == None)
|
|
|
|
.collect()
|
2024-07-25 00:26:29 +03:00
|
|
|
} else {
|
2024-07-25 10:55:29 +03:00
|
|
|
self.resolve_tasks(
|
|
|
|
self.tasks
|
|
|
|
.values()
|
|
|
|
.filter(|t| t.parent_id() == None)
|
|
|
|
.map(|t| &t.event.id),
|
|
|
|
)
|
2024-07-24 21:11:36 +03:00
|
|
|
}
|
2024-07-19 21:06:03 +03:00
|
|
|
},
|
2024-07-25 10:55:29 +03:00
|
|
|
|p| {
|
|
|
|
self.tasks
|
|
|
|
.get(&p)
|
|
|
|
.map_or(Vec::new(), |t| self.resolve_tasks(t.children.iter()))
|
|
|
|
},
|
2024-07-25 22:40:35 +03:00
|
|
|
);
|
|
|
|
if self.tags.is_empty() {
|
|
|
|
tasks
|
|
|
|
} else {
|
|
|
|
tasks
|
|
|
|
.into_iter()
|
|
|
|
.filter(|t| {
|
|
|
|
let mut iter = t.tags.iter();
|
|
|
|
self.tags.iter().all(|tag| iter.any(|t| t == tag))
|
|
|
|
})
|
|
|
|
.collect()
|
|
|
|
}
|
2024-07-19 09:35:03 +03:00
|
|
|
}
|
2024-07-19 01:15:11 +03:00
|
|
|
|
2024-07-19 09:35:03 +03:00
|
|
|
pub(crate) fn print_current_tasks(&self) {
|
2024-07-24 16:14:19 +03:00
|
|
|
println!("{}", self.properties.join("\t"));
|
2024-07-19 09:35:03 +03:00
|
|
|
for task in self.current_tasks() {
|
|
|
|
println!(
|
|
|
|
"{}",
|
|
|
|
self.properties
|
|
|
|
.iter()
|
|
|
|
.map(|p| match p.as_str() {
|
|
|
|
"path" => self.taskpath(Some(task.event.id)),
|
2024-07-25 10:55:29 +03:00
|
|
|
"rpath" => join_tasks(
|
|
|
|
self.traverse_up_from(Some(task.event.id))
|
|
|
|
.take_while(|t| Some(t.event.id) != self.position)
|
|
|
|
),
|
2024-07-19 09:44:12 +03:00
|
|
|
"ttime" => self.total_time_tracked(&task.event.id).to_string(),
|
2024-07-19 09:35:03 +03:00
|
|
|
prop => task.get(prop).unwrap_or(String::new()),
|
|
|
|
})
|
|
|
|
.collect::<Vec<String>>()
|
2024-07-24 16:14:19 +03:00
|
|
|
.join("\t")
|
2024-07-19 09:35:03 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
println!();
|
|
|
|
}
|
2024-07-19 21:06:03 +03:00
|
|
|
|
2024-07-25 22:10:01 +03:00
|
|
|
// Movement and Selection
|
|
|
|
|
|
|
|
pub(crate) fn set_filter(&mut self, view: Vec<EventId>) {
|
|
|
|
self.view = view
|
|
|
|
}
|
|
|
|
|
2024-07-25 22:40:35 +03:00
|
|
|
pub(crate) fn add_tag(&mut self, tag: String) {
|
|
|
|
self.view.clear();
|
|
|
|
self.tags.insert(Hashtag(tag));
|
|
|
|
}
|
|
|
|
|
2024-07-25 22:10:01 +03:00
|
|
|
pub(crate) fn move_up(&mut self) {
|
|
|
|
self.move_to(
|
|
|
|
self.position
|
|
|
|
.and_then(|id| self.tasks.get(&id))
|
|
|
|
.and_then(|t| t.parent_id()),
|
|
|
|
)
|
2024-07-24 16:03:34 +03:00
|
|
|
}
|
|
|
|
|
2024-07-25 22:10:01 +03:00
|
|
|
pub(crate) fn move_to(&mut self, id: Option<EventId>) {
|
|
|
|
self.view.clear();
|
2024-07-25 22:40:35 +03:00
|
|
|
self.tags.clear();
|
2024-07-25 22:10:01 +03:00
|
|
|
if id == self.position {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
self.update_state("", |s| {
|
|
|
|
if s.pure_state() == State::Active {
|
|
|
|
Some(State::Open)
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
});
|
|
|
|
self.position = id;
|
|
|
|
self.update_state("", |s| {
|
|
|
|
if s.pure_state() == State::Open {
|
|
|
|
Some(State::Active)
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Updates
|
|
|
|
|
2024-07-24 16:03:34 +03:00
|
|
|
pub(crate) fn build_task(&self, input: &str) -> EventBuilder {
|
2024-07-25 22:40:35 +03:00
|
|
|
let mut tags: Vec<Tag> = self.tags.iter().cloned().collect();
|
2024-07-19 01:15:11 +03:00
|
|
|
self.position.inspect(|p| tags.push(Tag::event(*p)));
|
|
|
|
return match input.split_once(": ") {
|
2024-07-24 16:03:34 +03:00
|
|
|
None => EventBuilder::new(Kind::from(TASK_KIND), input, tags),
|
2024-07-19 01:15:11 +03:00
|
|
|
Some(s) => {
|
2024-07-25 22:40:35 +03:00
|
|
|
tags.append(&mut s.1.split(" ").map(|t| Hashtag(t.to_string())).collect());
|
2024-07-24 16:03:34 +03:00
|
|
|
EventBuilder::new(Kind::from(TASK_KIND), s.0, tags)
|
2024-07-19 01:15:11 +03:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2024-07-25 22:10:01 +03:00
|
|
|
pub(crate) fn make_task(&mut self, input: &str) -> Option<EventId> {
|
|
|
|
self.sender.submit(self.build_task(input)).map(|e| {
|
|
|
|
let id = e.id;
|
|
|
|
self.add_task(e);
|
|
|
|
id
|
|
|
|
})
|
2024-07-19 16:49:23 +03:00
|
|
|
}
|
|
|
|
|
2024-07-19 21:04:21 +03:00
|
|
|
pub(crate) fn add(&mut self, event: Event) {
|
|
|
|
if event.kind.as_u64() == 1621 {
|
|
|
|
self.add_task(event)
|
|
|
|
} else {
|
|
|
|
self.add_prop(&event)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-07-19 16:49:23 +03:00
|
|
|
pub(crate) fn add_task(&mut self, event: Event) {
|
2024-07-25 10:55:29 +03:00
|
|
|
self.referenced_tasks(&event, |t| {
|
|
|
|
t.children.insert(event.id);
|
|
|
|
});
|
2024-07-24 16:03:34 +03:00
|
|
|
if self.tasks.contains_key(&event.id) {
|
|
|
|
//eprintln!("Did not insert duplicate event {}", event.id);
|
|
|
|
} else {
|
|
|
|
self.tasks.insert(event.id, Task::new(event));
|
|
|
|
}
|
2024-07-19 01:15:11 +03:00
|
|
|
}
|
2024-07-25 10:55:29 +03:00
|
|
|
|
2024-07-19 21:04:21 +03:00
|
|
|
pub(crate) fn add_prop(&mut self, event: &Event) {
|
2024-07-25 10:55:29 +03:00
|
|
|
self.referenced_tasks(&event, |t| {
|
|
|
|
t.props.insert(event.clone());
|
|
|
|
});
|
2024-07-19 21:04:21 +03:00
|
|
|
}
|
2024-07-19 01:15:11 +03:00
|
|
|
|
2024-07-23 13:45:25 +03:00
|
|
|
pub(crate) fn update_state_for<F>(&mut self, id: &EventId, comment: &str, f: F) -> Option<Event>
|
2024-07-19 01:15:11 +03:00
|
|
|
where
|
|
|
|
F: FnOnce(&Task) -> Option<State>,
|
|
|
|
{
|
2024-07-24 16:03:34 +03:00
|
|
|
self.tasks.get_mut(id).and_then(|task| {
|
2024-07-25 10:55:29 +03:00
|
|
|
f(task)
|
|
|
|
.and_then(|state| {
|
|
|
|
self.sender.submit(EventBuilder::new(
|
|
|
|
state.kind(),
|
|
|
|
comment,
|
|
|
|
vec![Tag::event(task.event.id)],
|
|
|
|
))
|
|
|
|
})
|
|
|
|
.inspect(|e| {
|
|
|
|
task.props.insert(e.clone());
|
|
|
|
})
|
2024-07-23 13:45:25 +03:00
|
|
|
})
|
2024-07-19 01:15:11 +03:00
|
|
|
}
|
|
|
|
|
2024-07-23 13:45:25 +03:00
|
|
|
pub(crate) fn update_state<F>(&mut self, comment: &str, f: F) -> Option<Event>
|
2024-07-19 01:15:11 +03:00
|
|
|
where
|
|
|
|
F: FnOnce(&Task) -> Option<State>,
|
|
|
|
{
|
2024-07-25 10:50:53 +03:00
|
|
|
self.position
|
|
|
|
.and_then(|id| self.update_state_for(&id, comment, f))
|
|
|
|
}
|
|
|
|
|
|
|
|
pub(crate) fn add_note(&mut self, note: &str) {
|
|
|
|
match self.position {
|
|
|
|
None => eprintln!("Cannot add note '{}' without active task", note),
|
|
|
|
Some(id) => {
|
|
|
|
self.sender
|
|
|
|
.submit(EventBuilder::text_note(note, vec![]))
|
|
|
|
.map(|e| {
|
|
|
|
self.tasks.get_mut(&id).map(|t| {
|
|
|
|
t.props.insert(e.clone());
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2024-07-19 01:15:11 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-07-25 10:55:29 +03:00
|
|
|
pub(crate) fn join_tasks<'a>(iter: impl IntoIterator<Item = &'a Task>) -> String {
|
2024-07-25 00:52:03 +03:00
|
|
|
iter.into_iter()
|
|
|
|
.map(|t| t.event.content.clone())
|
2024-07-25 10:55:29 +03:00
|
|
|
.fold(None, |acc, val| {
|
|
|
|
Some(acc.map_or_else(|| val.clone(), |cur| format!("{}>{}", val, cur)))
|
|
|
|
})
|
2024-07-25 00:52:03 +03:00
|
|
|
.unwrap_or(String::new())
|
|
|
|
}
|
|
|
|
|
2024-07-19 01:15:11 +03:00
|
|
|
struct ParentIterator<'a> {
|
|
|
|
tasks: &'a TaskMap,
|
|
|
|
current: Option<EventId>,
|
2024-07-19 16:49:23 +03:00
|
|
|
/// Inexpensive helper to assert correctness
|
|
|
|
prev: Option<EventId>,
|
2024-07-19 01:15:11 +03:00
|
|
|
}
|
|
|
|
impl<'a> Iterator for ParentIterator<'a> {
|
|
|
|
type Item = &'a Task;
|
|
|
|
|
|
|
|
fn next(&mut self) -> Option<Self::Item> {
|
|
|
|
self.current.and_then(|id| self.tasks.get(&id)).map(|t| {
|
2024-07-19 16:49:23 +03:00
|
|
|
self.prev.map(|id| assert!(t.children.contains(&id)));
|
|
|
|
self.prev = self.current;
|
2024-07-19 01:15:11 +03:00
|
|
|
self.current = t.parent_id();
|
|
|
|
t
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2024-07-25 00:26:29 +03:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_depth() {
|
2024-07-25 10:55:29 +03:00
|
|
|
use std::sync::mpsc;
|
|
|
|
|
2024-07-25 00:26:29 +03:00
|
|
|
let (tx, rx) = mpsc::channel();
|
|
|
|
let mut tasks = Tasks::from(EventSender {
|
|
|
|
tx,
|
|
|
|
keys: Keys::generate(),
|
|
|
|
});
|
|
|
|
let t1 = tasks.make_task("t1");
|
|
|
|
assert_eq!(tasks.depth, 1);
|
|
|
|
assert_eq!(tasks.current_tasks().len(), 1);
|
|
|
|
tasks.depth = 0;
|
|
|
|
assert_eq!(tasks.current_tasks().len(), 0);
|
2024-07-25 10:55:29 +03:00
|
|
|
|
2024-07-25 00:26:29 +03:00
|
|
|
tasks.move_to(t1);
|
|
|
|
tasks.depth = 2;
|
|
|
|
assert_eq!(tasks.current_tasks().len(), 0);
|
|
|
|
let t2 = tasks.make_task("t2");
|
|
|
|
assert_eq!(tasks.current_tasks().len(), 1);
|
|
|
|
let t3 = tasks.make_task("t3");
|
|
|
|
assert_eq!(tasks.current_tasks().len(), 2);
|
2024-07-25 10:55:29 +03:00
|
|
|
|
2024-07-25 00:26:29 +03:00
|
|
|
tasks.move_to(t2);
|
|
|
|
assert_eq!(tasks.current_tasks().len(), 0);
|
|
|
|
let t4 = tasks.make_task("t4");
|
|
|
|
assert_eq!(tasks.current_tasks().len(), 1);
|
|
|
|
tasks.depth = 2;
|
|
|
|
assert_eq!(tasks.current_tasks().len(), 1);
|
|
|
|
tasks.depth = -1;
|
|
|
|
assert_eq!(tasks.current_tasks().len(), 1);
|
|
|
|
|
|
|
|
tasks.move_to(t1);
|
|
|
|
assert_eq!(tasks.current_tasks().len(), 2);
|
|
|
|
tasks.depth = 2;
|
|
|
|
assert_eq!(tasks.current_tasks().len(), 3);
|
|
|
|
tasks.set_filter(vec![t2.unwrap()]);
|
|
|
|
assert_eq!(tasks.current_tasks().len(), 2);
|
|
|
|
tasks.depth = 1;
|
|
|
|
assert_eq!(tasks.current_tasks().len(), 1);
|
|
|
|
tasks.depth = -1;
|
|
|
|
assert_eq!(tasks.current_tasks().len(), 1);
|
|
|
|
tasks.set_filter(vec![t2.unwrap(), t3.unwrap()]);
|
|
|
|
assert_eq!(tasks.current_tasks().len(), 2);
|
|
|
|
tasks.depth = 2;
|
|
|
|
assert_eq!(tasks.current_tasks().len(), 3);
|
|
|
|
tasks.depth = 1;
|
|
|
|
assert_eq!(tasks.current_tasks().len(), 2);
|
|
|
|
|
|
|
|
tasks.move_to(None);
|
|
|
|
assert_eq!(tasks.current_tasks().len(), 1);
|
|
|
|
tasks.depth = 2;
|
|
|
|
assert_eq!(tasks.current_tasks().len(), 3);
|
|
|
|
tasks.depth = 3;
|
|
|
|
assert_eq!(tasks.current_tasks().len(), 4);
|
|
|
|
tasks.depth = 9;
|
|
|
|
assert_eq!(tasks.current_tasks().len(), 4);
|
|
|
|
tasks.depth = -1;
|
|
|
|
assert_eq!(tasks.current_tasks().len(), 2);
|
2024-07-25 10:55:29 +03:00
|
|
|
}
|