jesseduffield/lazygit · warning
No item selected
Error message
No item selected
What it means
Returned by ListControllerTrait.withItem when getSelectedItem() equals the zero value of T, meaning the list context has no selected row (empty list or no selection). It is the standard guard wrapping almost every per-item keybinding handler in lazygit's list views.
Source
Thrown at pkg/gui/controllers/list_controller_trait.go:113
}
for _, callback := range callbacks {
if reason := callback(items); reason != nil {
return reason
}
}
return nil
}
}
// Passes the selected item to the callback. Used for handler functions.
func (self *ListControllerTrait[T]) withItem(callback func(T) error) func() error {
return func() error {
var zeroValue T
commit := self.getSelectedItem()
if commit == zeroValue {
return errors.New(self.c.Tr.NoItemSelected)
}
return callback(commit)
}
}
func (self *ListControllerTrait[T]) withItems(callback func([]T) error) func() error {
return func() error {
items, _, _ := self.getSelectedItems()
if len(items) == 0 {
return errors.New(self.c.Tr.NoItemSelected)
}
return callback(items)
}
}
// like withItems but also passes the start and end index of the selectionView on GitHub (pinned to c477a2959b)
Solutions
- Populate the list first (e.g. create a commit/branch/remote) then retry the action.
- Wait for the view refresh to finish after an operation that empties the list before pressing the next key.
- For custom handlers, use withItemGraceful instead of withItem when the action should silently no-op on empty selection (as click handlers do).
Example fix
// before
Handle: func() error { return self.withItem(self.delete)(nil) },
// after (click-style actions that should no-op on empty space)
Handle: func() error { return self.withItemGraceful(self.delete)(nil) }, Defensive patterns
Strategy: validation
Validate before calling
if self.context().GetSelected() == nil { // or zero-value check for value types
return nil
} Prevention
- Use withItem for keybindings (error is desirable) and withItemGraceful for mouse clicks (no-op desired).
- Disable per-item keybindings via the controller's DisabledReason when the list can be empty.
- After any refresh that can empty a list, move focus/selection to a valid context.
When it happens
Trigger: Pressing a key whose handler was built via withItem(callback) while the focused list context is empty or has no highlighted row; e.g. deleting from an empty stash list or acting on an empty branches panel.
Common situations: Keybinding pressed the instant a view empties after a refresh (post-delete, post-checkout); custom keybindings bound to withItem-based handlers; empty repo states (no commits, no branches, no remotes).
Related errors
- You have already checked out this branch
- Some of the selected branches are checked out by other workt
- Cannot merge branch in detached head state. You might have c
- You cannot merge a branch into itself
- Cannot start interactive rebase: the HEAD commit is a merge
AI-assisted analysis of jesseduffield/lazygit@c477a2959b (2026-08-15).
Data as JSON: /api/errors/b8127e57b900a0d4.
Report an issue: GitHub.