diff --git a/src/timesheet.rs b/src/timesheet.rs index f53df77..38e90d0 100644 --- a/src/timesheet.rs +++ b/src/timesheet.rs @@ -83,8 +83,8 @@ impl TimeSheet { */ pub fn shift_current(&mut self, minutes: i64) { let time = &mut self.times[self.selected].time; - let current_minute = time.minute() as i64; - *time += Duration::minutes(minutes - current_minute % minutes); + *time += Duration::minutes(minutes); + *time -= Duration::minutes(time.minute() as i64 % 5) } fn current(&self) -> &TimePoint { diff --git a/src/tracc.rs b/src/tracc.rs index a859273..c83be4a 100644 --- a/src/tracc.rs +++ b/src/tracc.rs @@ -69,7 +69,10 @@ impl Tracc { } Key::Char('a') | Key::Char('A') => self.set_mode(Mode::Insert)?, Key::Char(' ') if self.focus == Focus::Top => self.todos.toggle_current(), - Key::Char('-') if self.focus == Focus::Bottom => self.times.shift_current(-5), + // Subtract only 1 minute because the number is truncated to the next multiple + // of 5 afterwards, so this is effectively a -5. + // See https://git.kageru.moe/kageru/tracc/issues/8 + Key::Char('-') if self.focus == Focus::Bottom => self.times.shift_current(-1), Key::Char('+') if self.focus == Focus::Bottom => self.times.shift_current(5), // dd Key::Char('d') => {