Skip to content

[sidePanelWidth]: Runtime error when value is 1.0Β #4582

@mrmerc

Description

@mrmerc

Describe the bug
When sidePanelWidth is set to 1.0, focusing preview window causes a runtime error

To Reproduce
Steps to reproduce the behavior:

lazygit_error.mp4
  1. Set config option sidePanelWidth to 1.0
  2. Relaunch lazygit, your 1-5 windows should take full width now
  3. Press + key, which should display the preview window on the right that you normally see, when sidePanelWidth has default value
  4. Select Commits window (number 4), press Enter on any commit and Enter again on any file in the commit
  5. Runtime error happens

Expected behavior

lazygit_expected.mp4

Preview window should be focused as expected

Version info:
commit=66caa25dcd4c247589e6adc71a6bc088678f3212, build date=2025-05-03T02:30:12Z, build source=binaryRelease, version=0.50.0, os=darwin, arch=arm64, git version=2.49.0

git version 2.49.0

Additional context

Error trace

panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
github.com/jesseduffield/lazycore/pkg/boxlayout.normalizeWeights({0x14000aff9f0, 0x2, 0x2})
/home/runner/work/lazygit/lazygit/vendor/github.com/jesseduffield/lazycore/pkg/boxlayout/boxlayout.go:161 +0x3d0
github.com/jesseduffield/lazycore/pkg/boxlayout.calcSizes({0x14000c385b0, 0x2, 0x14000f4ac78?}, 0x8d)
/home/runner/work/lazygit/lazygit/vendor/github.com/jesseduffield/lazycore/pkg/boxlayout/boxlayout.go:97 +0x6c
github.com/jesseduffield/lazycore/pkg/boxlayout.ArrangeWindows(0x14000c08280, 0x0, 0x0, 0x8d, 0x26)
/home/runner/work/lazygit/lazygit/vendor/github.com/jesseduffield/lazycore/pkg/boxlayout/boxlayout.go:75 +0xe0
github.com/jesseduffield/lazycore/pkg/boxlayout.ArrangeWindows(0x14000f4b090, 0x0, 0x0, 0x8d, 0x27)
/home/runner/work/lazygit/lazygit/vendor/github.com/jesseduffield/lazycore/pkg/boxlayout/boxlayout.go:86 +0x24c
github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers.GetWindowDimensions({0x8d, 0x27, 0x1400021f008, {0x100a73e7e, 0x4}, {0x100a73e7e, 0x4}, {0x100a760e5, 0x5}, 0x0, ...})
/home/runner/work/lazygit/lazygit/pkg/gui/controllers/helpers/window_arrangement_helper.go:168 +0x438
github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers.(*WindowArrangementHelper).GetWindowDimensions(0x14000542100, {0x14000a30370, 0xa5}, {0x0, 0x0})
/home/runner/work/lazygit/lazygit/pkg/gui/controllers/helpers/window_arrangement_helper.go:106 +0x308
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).getWindowDimensions(...)
/home/runner/work/lazygit/lazygit/pkg/gui/gui.go:1134
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).layout(0x14000240308, 0x14000270000)
/home/runner/work/lazygit/lazygit/pkg/gui/layout.go:26 +0x10c
github.com/jesseduffield/gocui.ManagerFunc.Layout(0x0?, 0x140017990a0?)
/home/runner/work/lazygit/lazygit/vendor/github.com/jesseduffield/gocui/gui.go:728 +0x28
github.com/jesseduffield/gocui.(*Gui).flush(0x14000270000)
/home/runner/work/lazygit/lazygit/vendor/github.com/jesseduffield/gocui/gui.go:1185 +0xac
github.com/jesseduffield/gocui.(*Gui).processEvent(0x14000270000)
/home/runner/work/lazygit/lazygit/vendor/github.com/jesseduffield/gocui/gui.go:813 +0x208
github.com/jesseduffield/gocui.(*Gui).MainLoop(0x14000270000)
/home/runner/work/lazygit/lazygit/vendor/github.com/jesseduffield/gocui/gui.go:778 +0x108
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).Run(0x14000240308, {{0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}})
/home/runner/work/lazygit/lazygit/pkg/gui/gui.go:867 +0x434
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).RunAndHandleError.func1()
/home/runner/work/lazygit/lazygit/pkg/gui/gui.go:873 +0x48
github.com/jesseduffield/lazygit/pkg/utils.SafeWithError(0x14000043928?)
/home/runner/work/lazygit/lazygit/pkg/utils/utils.go:90 +0x5c
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).RunAndHandleError(0x14000240308, {{0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}})
/home/runner/work/lazygit/lazygit/pkg/gui/gui.go:872 +0xc4
github.com/jesseduffield/lazygit/pkg/app.(*App).Run(...)
/home/runner/work/lazygit/lazygit/pkg/app/app.go:270
github.com/jesseduffield/lazygit/pkg/app.Run({0x100e6bfb8?, 0x140000cc6e0?}, 0x140001f71c0, {{0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}, {0x0, ...}})
/home/runner/work/lazygit/lazygit/pkg/app/app.go:48 +0xb0
github.com/jesseduffield/lazygit/pkg/app.Start(0x14000043ef8, {0x0, 0x0})
/home/runner/work/lazygit/lazygit/pkg/app/entry_point.go:168 +0x9b0
main.main()
/home/runner/work/lazygit/lazygit/main.go:23 +0x98

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions