Skip to content

Commit

Permalink
fix: resize effect on unselected repos
Browse files Browse the repository at this point in the history
  • Loading branch information
caarlos0 authored and toby committed Nov 1, 2021
1 parent 71196d8 commit 88803aa
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions internal/tui/bubble.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
"github.com/charmbracelet/soft/internal/config"
"github.com/charmbracelet/soft/internal/git"
"github.com/charmbracelet/soft/internal/tui/bubbles/repo"
"github.com/charmbracelet/soft/internal/tui/bubbles/selection"
"github.com/charmbracelet/soft/internal/tui/style"
Expand Down Expand Up @@ -47,11 +46,13 @@ type Bubble struct {
height int
initialRepo string
repoMenu []MenuEntry
repos []*git.Repo
boxes []tea.Model
activeBox int
repoSelect *selection.Bubble
session ssh.Session

// remember the last resize so we can re-send it when selecting a different repo.
lastResize tea.WindowSizeMsg
}

func NewBubble(cfg *config.Config, sCfg *SessionConfig) *Bubble {
Expand Down Expand Up @@ -96,6 +97,7 @@ func (b *Bubble) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
b.state = errorState
return b, nil
case tea.WindowSizeMsg:
b.lastResize = msg
b.width = msg.Width
b.height = msg.Height
if b.state == loadedState {
Expand All @@ -116,6 +118,9 @@ func (b *Bubble) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
rb := b.repoMenu[msg.Index].bubble
rb.GotoTop()
b.boxes[1] = b.repoMenu[msg.Index].bubble
cmds = append(cmds, func() tea.Msg {
return b.lastResize
})
}
if b.state == loadedState {
ab, cmd := b.boxes[b.activeBox].Update(msg)
Expand Down

0 comments on commit 88803aa

Please sign in to comment.