diff --git a/common/keymap.go b/common/keymap.go index 806e82f..e6df97a 100644 --- a/common/keymap.go +++ b/common/keymap.go @@ -28,6 +28,7 @@ type Keymap struct { Insert key.Binding Tag key.Binding Undo key.Binding + Fill key.Binding StartStop key.Binding } @@ -145,6 +146,11 @@ func NewKeymap() *Keymap { key.WithHelp("undo", "Undo"), ), + Fill: key.NewBinding( + key.WithKeys("f"), + key.WithHelp("fill", "Fill gaps"), + ), + StartStop: key.NewBinding( key.WithKeys("s"), key.WithHelp("start/stop", "Start/Stop"), diff --git a/pages/timePage.go b/pages/timePage.go index b04e37f..44c8541 100644 --- a/pages/timePage.go +++ b/pages/timePage.go @@ -83,6 +83,16 @@ func (p *TimePage) Update(msg tea.Msg) (tea.Model, tea.Cmd) { editor := NewTimeEditorPage(p.common, interval) p.common.PushPage(p) return editor, editor.Init() + case key.Matches(msg, p.common.Keymap.Fill): + row := p.intervals.SelectedRow() + if row != nil { + interval := (*timewarrior.Interval)(row) + p.common.TimeW.FillInterval(interval.ID) + return p, tea.Batch(p.getIntervals(), doTick()) + } + case key.Matches(msg, p.common.Keymap.Undo): + p.common.TimeW.Undo() + return p, tea.Batch(p.getIntervals(), doTick()) } } diff --git a/test/taskchampion.sqlite3-shm b/test/taskchampion.sqlite3-shm deleted file mode 100644 index fe9ac28..0000000 Binary files a/test/taskchampion.sqlite3-shm and /dev/null differ diff --git a/test/taskchampion.sqlite3-wal b/test/taskchampion.sqlite3-wal deleted file mode 100644 index e69de29..0000000 diff --git a/timewarrior/timewarrior.go b/timewarrior/timewarrior.go index cd96656..5a6336d 100644 --- a/timewarrior/timewarrior.go +++ b/timewarrior/timewarrior.go @@ -30,6 +30,7 @@ type TimeWarrior interface { ContinueInterval(id int) error CancelTracking() error DeleteInterval(id int) error + FillInterval(id int) error ModifyInterval(interval *Interval, adjust bool) error GetSummary(filter ...string) string GetActive() *Interval @@ -218,6 +219,19 @@ func (ts *TimeSquire) DeleteInterval(id int) error { return nil } +func (ts *TimeSquire) FillInterval(id int) error { + ts.mutex.Lock() + defer ts.mutex.Unlock() + + cmd := exec.Command(twBinary, append(ts.defaultArgs, []string{"fill", fmt.Sprintf("@%d", id)}...)...) + if err := cmd.Run(); err != nil { + slog.Error("Failed filling interval:", err) + return err + } + + return nil +} + func (ts *TimeSquire) ModifyInterval(interval *Interval, adjust bool) error { ts.mutex.Lock() defer ts.mutex.Unlock()