jesseduffield / lazygit

simple terminal UI for git commands

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Lazygit crashes when searching in keybinding menu.

crazytaxi824 opened this issue · comments

Describe the bug
Lazygit crashes when searching in keybinding menu.

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'local branch'
  2. press '?' enter keybindings menu.
  3. press '/' enter filter mode.
  4. press 'fa'
  5. software crashes.
panic: runtime error: index out of range [1] with length 1

goroutine 1 [running]:
github.com/jesseduffield/lazygit/pkg/gui/context.(*ListRenderer).insertNonModelItems(0x140005dbb78?, {0x14000f2e048, 0x1, 0x1400096c290?}, 0x2, 0x0, {0x140007133b0?, 0x102e2d594?, 0x140000a7cc0?}, {0x1400063e3f0, ...})
	github.com/jesseduffield/lazygit/pkg/gui/context/list_renderer.go:118 +0x31c
github.com/jesseduffield/lazygit/pkg/gui/context.(*ListRenderer).renderLines(0x14000127890, 0xffffffffffffffff, 0xffffffffffffffff)
	github.com/jesseduffield/lazygit/pkg/gui/context/list_renderer.go:90 +0x1a4
github.com/jesseduffield/lazygit/pkg/gui/context.(*ListContextTrait).HandleRender(0x14000127880)
	github.com/jesseduffield/lazygit/pkg/gui/context/list_context_trait.go:96 +0x44
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).postRefreshUpdate(0x14000122f08, {0x1032db5b8, 0x1400000ea98})
	github.com/jesseduffield/lazygit/pkg/gui/view_helpers.go:139 +0x98
github.com/jesseduffield/lazygit/pkg/gui.(*guiCommon).PostRefreshUpdate(0x103917720?, {0x1032db5b8?, 0x1400000ea98?})
	github.com/jesseduffield/lazygit/pkg/gui/gui_common.go:33 +0x28
github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers.(*SearchHelper).OnPromptContentChanged(0x1400007c920, {0x1400063e270, 0x2})
	github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers/search_helper.go:222 +0x228
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).searchEditor(0x14000122f08, 0x140003bf400, 0x53e8?, 0x140?, 0x21c0?)
	github.com/jesseduffield/lazygit/pkg/gui/editors.go:98 +0x74
github.com/jesseduffield/gocui.EditorFunc.Edit(0x140005f5610?, 0x2?, 0x0?, 0x0?, 0x75c8?)
	github.com/jesseduffield/gocui@v0.3.1-0.20240309085756-86e0d5a312de/edit.go:23 +0x34
github.com/jesseduffield/gocui.(*Gui).execKeybindings(0x14000104c40, 0x140003bf400, 0x140005f5590)
	github.com/jesseduffield/gocui@v0.3.1-0.20240309085756-86e0d5a312de/gui.go:1438 +0x408
github.com/jesseduffield/gocui.(*Gui).onKey(0x140000ba628?, 0x140005f5510?)
	github.com/jesseduffield/gocui@v0.3.1-0.20240309085756-86e0d5a312de/gui.go:1281 +0xc8
github.com/jesseduffield/gocui.(*Gui).handleEvent(0x140000ba600?, 0x140005f5578?)
	github.com/jesseduffield/gocui@v0.3.1-0.20240309085756-86e0d5a312de/gui.go:800 +0x54
github.com/jesseduffield/gocui.(*Gui).processEvent(0x14000104c40)
	github.com/jesseduffield/gocui@v0.3.1-0.20240309085756-86e0d5a312de/gui.go:754 +0x178
github.com/jesseduffield/gocui.(*Gui).MainLoop(0x14000104c40)
	github.com/jesseduffield/gocui@v0.3.1-0.20240309085756-86e0d5a312de/gui.go:741 +0xac
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).Run(0x14000122f08, {{0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}})
	github.com/jesseduffield/lazygit/pkg/gui/gui.go:705 +0x52c
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).RunAndHandleError.func1()
	github.com/jesseduffield/lazygit/pkg/gui/gui.go:711 +0x40
github.com/jesseduffield/lazygit/pkg/utils.SafeWithError(0x140002a0b70?)
	github.com/jesseduffield/lazygit/pkg/utils/utils.go:117 +0x60
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).RunAndHandleError(0x14000122f08, {{0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}})
	github.com/jesseduffield/lazygit/pkg/gui/gui.go:710 +0xac
github.com/jesseduffield/lazygit/pkg/app.(*App).Run(...)
	github.com/jesseduffield/lazygit/pkg/app/app.go:266
github.com/jesseduffield/lazygit/pkg/app.Run({0x1032d57d0?, 0x140002c2be0?}, 0x1400013d5c0, {{0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}})
	github.com/jesseduffield/lazygit/pkg/app/app.go:49 +0x9c
github.com/jesseduffield/lazygit/pkg/app.Start(0x14000051ef8, {0x0, 0x0})
	github.com/jesseduffield/lazygit/pkg/app/entry_point.go:150 +0x9ac
main.main()
	github.com/jesseduffield/lazygit/main.go:23 +0x98

Version info:
_Run lazygit --version
commit=, build date=, build source=homebrew, version=0.41.0, os=darwin, arch=arm64, git version=2.44.0

_Run git --version
git version 2.44.0

macOS 14.4.1

Doesn't crash for me, I wonder what's different on your machine. Do you have any custom commands configured?

I tested it again. I have set some of the keybindings to null. When the search result hits the one with null keybindings, it crashes.

Ah, thanks, easy to reproduce. Here's a fix: #3450.