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

Activity

ChrisMcD1

ChrisMcD1 commented on May 23, 2025

@ChrisMcD1
Contributor

@mrmerc

Hey, thanks for the report! Easy to reproduce. I'm curious, is this an actual standard part of your flow, or did you just discover it while messing around?

I'm continuing to look into

mrmerc

mrmerc commented on May 23, 2025

@mrmerc
Author

@ChrisMcD1 hey, I rarely need the preview window, thus I tweaked the config option to make lazygit main windows fullscreen. Bug was discovered by accident.

linked a pull request that will close this issue on May 23, 2025
ChrisMcD1

ChrisMcD1 commented on May 23, 2025

@ChrisMcD1
Contributor

Okay, interesting!

Well, the fix ended up being pretty easy in this case #4583

I also added a 2nd commit just now (while typing this) to that PR that also makes this behavior work on the main screen without you needing to press + to go to the split screen mode.

There might still be other problems with this setting choice. I don't think it's something that was truly intended 😅 A lot of stuff might subtly rely on the main view being visible. But if you're willing to be a bit of a trailblazer, good on ya!

mrmerc

mrmerc commented on May 23, 2025

@mrmerc
Author

Thank you for the fixes 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @mrmerc@ChrisMcD1

      Issue actions

        [sidePanelWidth]: Runtime error when value is 1.0 · Issue #4582 · jesseduffield/lazygit