diff --git a/file/file.go b/file/file.go index c5ff450..b0147e0 100644 --- a/file/file.go +++ b/file/file.go @@ -29,10 +29,6 @@ func (m model) Init() tea.Cmd { func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { switch msg := msg.(type) { - case filepicker.FileSelectedMsg: - m.selectedPath = msg.Path - m.quitting = true - return m, tea.Quit case tea.KeyMsg: switch msg.String() { case "ctrl+c", "q": @@ -41,6 +37,11 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } var cmd tea.Cmd m.filepicker, cmd = m.filepicker.Update(msg) + if didSelect, path := m.filepicker.DidSelectFile(msg); didSelect { + m.selectedPath = path + m.quitting = true + return m, tea.Quit + } return m, cmd } diff --git a/go.mod b/go.mod index 6ab0b94..23bd1ea 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.18 require ( github.com/alecthomas/kong v0.7.1 github.com/alecthomas/mango-kong v0.1.0 - github.com/charmbracelet/bubbles v0.15.1-0.20230303175231-2694acc38055 + github.com/charmbracelet/bubbles v0.15.1-0.20230303214459-958a0ea710f1 github.com/charmbracelet/bubbletea v0.23.2 github.com/charmbracelet/glamour v0.6.0 github.com/charmbracelet/lipgloss v0.6.1-0.20230222162833-a74950e6da16 diff --git a/go.sum b/go.sum index 08ab007..638e29c 100644 --- a/go.sum +++ b/go.sum @@ -25,6 +25,8 @@ github.com/charmbracelet/bubbles v0.15.0 h1:c5vZ3woHV5W2b8YZI1q7v4ZNQaPetfHuoHzx github.com/charmbracelet/bubbles v0.15.0/go.mod h1:Y7gSFbBzlMpUDR/XM9MhZI374Q+1p1kluf1uLl8iK74= github.com/charmbracelet/bubbles v0.15.1-0.20230303175231-2694acc38055 h1:4zkjfTm5xydSP+cZjgWyAmrjJXlx0E0E2DWu4x3r0vM= github.com/charmbracelet/bubbles v0.15.1-0.20230303175231-2694acc38055/go.mod h1:2ZpQTAUWMFMWM5lx7FvucnwMOE+/JKP9d/Su1MKpZbo= +github.com/charmbracelet/bubbles v0.15.1-0.20230303214459-958a0ea710f1 h1:BcxSgchb4ZV1lJe9W9+LhQj6S3JouC39yYswVI4YOrw= +github.com/charmbracelet/bubbles v0.15.1-0.20230303214459-958a0ea710f1/go.mod h1:39HL8bnL0foloiENA/KvD+3mNg5SqWQV2Qh3eY/4ey4= github.com/charmbracelet/bubbletea v0.22.1/go.mod h1:8/7hVvbPN6ZZPkczLiB8YpLkLJ0n7DMho5Wvfd2X1C0= github.com/charmbracelet/bubbletea v0.23.1/go.mod h1:JAfGK/3/pPKHTnAS8JIE2u9f61BjWTQY57RbT25aMXU= github.com/charmbracelet/bubbletea v0.23.2 h1:vuUJ9HJ7b/COy4I30e8xDVQ+VRDUEFykIjryPfgsdps=