mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Handle cases in which there is no git repo data
This commit is contained in:
parent
f1a2f65bf1
commit
9ec1b516c1
@ -10,6 +10,10 @@ func (widget *Widget) display() {
|
||||
widget.View.Clear()
|
||||
|
||||
repoData := widget.currentData()
|
||||
if repoData == nil {
|
||||
fmt.Fprintf(widget.View, "%s", " Git repo data is unavailable (1)")
|
||||
return
|
||||
}
|
||||
|
||||
title := fmt.Sprintf("[green]%s[white]\n", repoData.Repository)
|
||||
widget.View.SetTitle(fmt.Sprintf(" Git: %s ", title))
|
||||
|
@ -5,7 +5,6 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
||||
"github.com/gdamore/tcell"
|
||||
"github.com/olebedev/config"
|
||||
"github.com/senorprogrammer/wtf/wtf"
|
||||
@ -78,7 +77,15 @@ func (widget *Widget) Prev() {
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
||||
func (widget *Widget) currentData() *GitRepo {
|
||||
return widget.Data[widget.Idx]
|
||||
if len(widget.Data) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
if widget.Idx < 0 || widget.Idx >= len(widget.Data) {
|
||||
return nil
|
||||
}
|
||||
|
||||
return widget.Data[widget.Idx]
|
||||
}
|
||||
|
||||
func (widget *Widget) keyboardIntercept(event *tcell.EventKey) *tcell.EventKey {
|
||||
|
Loading…
x
Reference in New Issue
Block a user