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 selection

View on GitHub (pinned to c477a2959b)

Solutions

  1. Populate the list first (e.g. create a commit/branch/remote) then retry the action.
  2. Wait for the view refresh to finish after an operation that empties the list before pressing the next key.
  3. 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

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


AI-assisted analysis of jesseduffield/lazygit@c477a2959b (2026-08-15). Data as JSON: /api/errors/b8127e57b900a0d4. Report an issue: GitHub.