From 1e87393d0709ee05585b910c5be3def089f73a7d Mon Sep 17 00:00:00 2001 From: filifa Date: Sat, 7 Sep 2024 19:20:09 -0500 Subject: [PATCH] don't crash when no presets are passed --- cmd/root.go | 4 +++- cmd/window.go | 12 ++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index 5e74d06..c2de197 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -150,7 +150,9 @@ func milkbucket(cmd *cobra.Command, args []string) { } defer m.destroy() - m.loadPreset(false) + if len(args) > 0 { + m.loadPreset(false) + } running := true for running { diff --git a/cmd/window.go b/cmd/window.go index 8f16aa5..b2fa4fa 100644 --- a/cmd/window.go +++ b/cmd/window.go @@ -67,8 +67,10 @@ func (m *milkDropWindow) setupPresets(presets []string) { * preset. */ func (m *milkDropWindow) nextPreset(smooth bool) { - m.preset = m.preset.Next() - m.loadPreset(smooth) + if m.preset.Len() > 0 { + m.preset = m.preset.Next() + m.loadPreset(smooth) + } } /* @@ -76,8 +78,10 @@ func (m *milkDropWindow) nextPreset(smooth bool) { * preset. */ func (m *milkDropWindow) prevPreset(smooth bool) { - m.preset = m.preset.Prev() - m.loadPreset(smooth) + if m.preset.Len() > 0 { + m.preset = m.preset.Prev() + m.loadPreset(smooth) + } } /*