Change summary
ui/components/code/code.go | 2 ++
ui/pages/repo/repo.go | 7 ++++++-
ui/ui.go | 17 +++++++++++++++--
3 files changed, 23 insertions(+), 3 deletions(-)
Detailed changes
@@ -139,6 +139,8 @@ func (r *Code) ScrollPercent() float64 {
func styleConfig() gansi.StyleConfig {
noColor := ""
s := glamour.DarkStyleConfig
+ // This fixes an issue with the default style config. For example
+ // highlighting empty spaces with red in Dockerfile type.
s.Document.StylePrimitive.Color = &noColor
s.CodeBlock.Chroma.Text.Color = &noColor
s.CodeBlock.Chroma.Name.Color = &noColor
@@ -146,7 +146,12 @@ func (r *Repo) FullHelp() [][]key.Binding {
// Init implements tea.View.
func (r *Repo) Init() tea.Cmd {
- return nil
+ cmds := make([]tea.Cmd, 0)
+ cmds = append(cmds,
+ r.tabs.Init(),
+ r.statusbar.Init(),
+ )
+ return tea.Batch(cmds...)
}
// Update implements tea.Model.
@@ -118,11 +118,24 @@ func (ui *UI) Init() tea.Cmd {
ui.pages[selectionPage] = selection.New(ui.s, ui.common)
ui.pages[repoPage] = repo.New(ui.common, &source{cfg.Source})
ui.SetSize(ui.common.Width, ui.common.Height)
- ui.state = loadedState
- return tea.Batch(
+ cmd := tea.Batch(
ui.pages[selectionPage].Init(),
ui.pages[repoPage].Init(),
)
+ var msg tea.Msg
+ if cmd != nil {
+ msg = cmd()
+ switch msg := msg.(type) {
+ case common.ErrorMsg:
+ ui.state = errorState
+ return common.ErrorCmd(msg)
+ }
+ }
+ ui.state = loadedState
+ if msg != nil {
+ return func() tea.Msg { return msg }
+ }
+ return nil
}
// Update implements tea.Model.