Skip to content

Commit e75d749

Browse files
authored
fix: close split view (#1315)
## What? Handles `esc` in split view screen to close the split view, instead of returning to the home screen. ## Why? Closes #1313 Signed-off-by: drew <me@andrinoff.com>
1 parent d1fe53c commit e75d749

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ func (m *mainModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
235235
var cmds []tea.Cmd
236236
searchWasActive := false
237237
filterWasActive := false
238+
splitWasOpen := false
238239

239240
if keyMsg, ok := msg.(tea.KeyPressMsg); ok && keyMsg.String() == config.Keybinds.Global.Cancel {
240241
switch current := m.current.(type) {
@@ -246,6 +247,7 @@ func (m *mainModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
246247
searchWasActive = inbox.IsSearchActive()
247248
filterWasActive = inbox.IsFilterActive()
248249
}
250+
splitWasOpen = current.HasSplitPreview()
249251
}
250252
}
251253

@@ -287,7 +289,7 @@ func (m *mainModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
287289
case *tui.FilePicker:
288290
return m, func() tea.Msg { return tui.CancelFilePickerMsg{} }
289291
case *tui.FolderInbox, *tui.Inbox, *tui.Login:
290-
if searchWasActive || filterWasActive {
292+
if searchWasActive || filterWasActive || splitWasOpen {
291293
return m, tea.Batch(cmds...)
292294
}
293295
m.idleWatcher.StopAll()

tui/folder_inbox.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,11 @@ func (m *FolderInbox) GetCurrentFolder() string {
685685
return m.currentFolder
686686
}
687687

688+
// HasSplitPreview reports whether the split preview pane is currently open.
689+
func (m *FolderInbox) HasSplitPreview() bool {
690+
return m.previewPane != nil
691+
}
692+
688693
// GetInbox returns the embedded inbox.
689694
func (m *FolderInbox) GetInbox() *Inbox {
690695
return m.inbox

0 commit comments

Comments
 (0)