Skip to content

Commit

Permalink
fix a display problem caused by daily hook checkout
Browse files Browse the repository at this point in the history
  • Loading branch information
jfding committed Oct 9, 2024
1 parent a4838cf commit e46b60e
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/taskbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,22 +211,31 @@ impl TaskBox {
}

pub fn collect_from(&mut self, tb_from: &mut TaskBox) {
self.load(); tb_from.load();
fn _get_nickname(fp: &Path) -> String {
let title_from_fp = fp.file_stem()
.and_then(|s| s.to_str())
.unwrap()
.to_string();
get_box_alias(&title_from_fp).unwrap_or(title_from_fp)
}

let tasks = tb_from.get_all_to_mark();
if tasks.is_empty() { return }
let tasks_in = tb_from.get_all_to_mark();
if tasks_in.is_empty() { return }

if let Some(ref selected) = tb_from.selected {
if selected.is_empty() { return }
}

// print title line
let from = tb_from.alias.clone().unwrap_or(tb_from.title.clone().unwrap());
let to = self.alias.clone().unwrap_or(self.title.clone().unwrap());
let from = _get_nickname(&tb_from.fpath);
let to = _get_nickname(&self.fpath);
println!("{} {} {} {}", S_movefrom!(from), MOVING,
S_moveto!(to), PROGRESS);

for task in tasks {
// postpone self.load() to avoid stdio chaos(from daily hook)
self.load();

for task in tasks_in {
if let Some(ref selected) = tb_from.selected {
if ! selected.contains(&task) { continue }
}
Expand Down

0 comments on commit e46b60e

Please sign in to comment.