Detailed changes
@@ -196,7 +196,9 @@ func (ui *UI) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
ui.common.Zone.Close()
return ui, tea.Quit
}
- case ui.activePage == repoPage && key.Matches(msg, ui.common.KeyMap.Back):
+ case ui.activePage == repoPage &&
+ ui.pages[ui.activePage].(*repo.Repo).Path() == "" &&
+ key.Matches(msg, ui.common.KeyMap.Back):
ui.activePage = selectionPage
// Always show the footer on selection page.
ui.showFooter = true
@@ -28,4 +28,7 @@ type TabComponent interface {
// TabName returns the name of the tab.
TabName() string
+
+ // Path returns the hierarchical path of the tab.
+ Path() string
}
@@ -105,6 +105,15 @@ func NewFiles(common common.Common) *Files {
return f
}
+// Path implements common.TabComponent.
+func (f *Files) Path() string {
+ path := f.path
+ if path == "." {
+ return ""
+ }
+ return path
+}
+
// TabName returns the tab name.
func (f *Files) TabName() string {
return "Files"
@@ -83,6 +83,16 @@ func NewLog(common common.Common) *Log {
return l
}
+// Path implements common.TabComponent.
+func (l *Log) Path() string {
+ switch l.activeView {
+ case logViewCommits:
+ return ""
+ default:
+ return "diff" // XXX: this is a place holder and doesn't mean anything
+ }
+}
+
// TabName returns the name of the tab.
func (l *Log) TabName() string {
return "Commits"
@@ -45,6 +45,11 @@ func NewReadme(common common.Common) *Readme {
}
}
+// Path implements common.TabComponent.
+func (r *Readme) Path() string {
+ return ""
+}
+
// TabName returns the name of the tab.
func (r *Readme) TabName() string {
return "Readme"
@@ -57,6 +57,11 @@ func NewRefs(common common.Common, refPrefix string) *Refs {
return r
}
+// Path implements common.TabComponent.
+func (r *Refs) Path() string {
+ return ""
+}
+
// TabName returns the name of the tab.
func (r *Refs) TabName() string {
if r.refPrefix == git.RefsHeads {
@@ -104,6 +104,11 @@ func (r *Repo) SetSize(width, height int) {
}
}
+// Path returns the current component path.
+func (r *Repo) Path() string {
+ return r.panes[r.activeTab].Path()
+}
+
func (r *Repo) commonHelp() []key.Binding {
b := make([]key.Binding, 0)
back := r.common.KeyMap.Back
@@ -194,6 +199,13 @@ func (r *Repo) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}
}
}
+ switch msg := msg.(type) {
+ case tea.KeyMsg:
+ switch {
+ case key.Matches(msg, r.common.KeyMap.Back):
+ cmds = append(cmds, goBackCmd)
+ }
+ }
case CopyMsg:
txt := msg.Text
if cfg := r.common.Config(); cfg != nil {
@@ -64,6 +64,11 @@ func NewStash(common common.Common) *Stash {
}
}
+// Path implements common.TabComponent.
+func (s *Stash) Path() string {
+ return ""
+}
+
// TabName returns the name of the tab.
func (s *Stash) TabName() string {
return "Stash"