Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion pkg/ui/tui.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,15 @@ type mainModel struct {
}

func New(input string, cfg config.Config) mainModel {
initialPanel := FileTreePanel
if !cfg.UI.ShowFileTree {
initialPanel = DiffViewerPanel
}

m := mainModel{
input: input,
isShowingFileTree: cfg.UI.ShowFileTree,
activePanel: FileTreePanel,
activePanel: initialPanel,
config: cfg,
iconStyle: cfg.UI.Icons,
sideBySide: cfg.UI.SideBySide,
Expand Down
24 changes: 24 additions & 0 deletions pkg/ui/tui_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,30 @@ func TestSearchSidebarDragMotionIsIgnored(t *testing.T) {
}
}

func TestInitialActivePanelWhenFileTreeIsHidden(t *testing.T) {
zone.NewGlobal()

cfg := config.DefaultConfig()
cfg.UI.ShowFileTree = false

data, err := os.ReadFile("../../examples/multiple_files.txt")
if err != nil {
t.Fatal(err)
}

m := New(string(data), cfg)

if m.activePanel != DiffViewerPanel {
t.Fatalf(
"expected activePanel to be DiffViewerPanel when showFileTree is false, got %v",
m.activePanel,
)
}
if m.isShowingFileTree {
t.Fatal("expected file tree to be hidden when showFileTree is false")
}
}

func newTestMainModel(t *testing.T) mainModel {
t.Helper()
zone.NewGlobal()
Expand Down
Loading