fix(tasks): adjust make_dependent_sibling to new state logic

This commit is contained in:
xeruf 2025-05-11 16:27:42 +02:00
parent 3652a290b2
commit 32fbf6db89
2 changed files with 8 additions and 4 deletions

View file

@ -894,8 +894,10 @@ impl TasksRelay {
self.state = state;
}
pub(crate) fn move_up(&mut self) {
self.move_to(self.get_current_task().and_then(|t| t.parent_id()).cloned());
pub(crate) fn move_up(&mut self) -> Option<EventId> {
let parent = self.get_current_task().and_then(|t| t.parent_id()).cloned();
self.move_to(parent);
parent
}
pub(crate) fn flush(&self) {
@ -1093,10 +1095,10 @@ impl TasksRelay {
/// Returns true if successful, false if there is no current task
pub(crate) fn make_dependent_sibling(&mut self, input: &str) -> bool {
if let Some(pos) = self.get_position() {
self.move_up();
let parent = self.move_up();
self.make_task_with(
input,
self.get_position()
parent
.map(|par| self.make_event_tag_from_id(par, MARKER_PARENT))
.into_iter()
.chain(once(self.make_event_tag_from_id(pos, MARKER_DEPENDS))),

View file

@ -193,11 +193,13 @@ fn test_sibling_dependency() {
);
assert_tasks_view!(tasks, [parent]);
tasks.track_at(Timestamp::now(), Some(sub));
tasks.update_position();
assert_eq!(tasks.get_own_events_history().count(), 1);
assert_tasks_view!(tasks, []);
tasks.make_dependent_sibling("sibling");
assert_eq!(tasks.len(), 3);
tasks.update_position();
assert_eq!(tasks.viewed_tasks().len(), 2);
}