wagoodman/dive · warning

unable to move the cursor, empty line

Error message

unable to move the cursor, empty line

What it means

Returned by CursorStep in the interactive gocui UI when the user tries to move the file-tree cursor onto a line whose rendered text is empty. Before moving the cursor the code calls v.Line(cy+step); if that line has zero length it refuses to move. This typically happens at the bottom of the filtered file tree, where the view still has drawable rows but no more tree content.

Source

Thrown at cmd/dive/cli/internal/ui/v1/view/cursor.go:29

	return CursorStep(g, v, 1)
}

// CursorUp moves the cursor up in the currently selected gocui pane, scrolling the screen as needed.
func CursorUp(g *gocui.Gui, v *gocui.View) error {
	return CursorStep(g, v, -1)
}

// Moves the cursor the given step distance, setting the origin to the new cursor line
func CursorStep(g *gocui.Gui, v *gocui.View, step int) error {
	cx, cy := v.Cursor()

	// if there isn't a next line
	line, err := v.Line(cy + step)
	if err != nil {
		return err
	}
	if len(line) == 0 {
		return errors.New("unable to move the cursor, empty line")
	}
	if err := v.SetCursor(cx, cy+step); err != nil {
		ox, oy := v.Origin()
		if err := v.SetOrigin(ox, oy+step); err != nil {
			return err
		}
	}
	return nil
}

View on GitHub (pinned to d6c691947f)

Solutions

  1. No fix needed for data — this is a soft navigation boundary; simply do not move further in that direction
  2. If it appears mid-tree, check for a custom keybinding with a large step value and reduce it
  3. If a filtered view shows blank rows inside the tree, clear the filter (press / then Escape or the reset key) and retry navigation
  4. Developers patching the UI can treat an empty target line as 'clamp to last valid row' instead of returning an error

Example fix

// before
if len(line) == 0 {
    return errors.New("unable to move the cursor, empty line")
}

// after (clamp instead of erroring)
if len(line) == 0 {
    return nil // at the edge of the tree; ignore the move
}
Defensive patterns

Strategy: validation

Validate before calling

// callers of CursorStep: skip moves past the last visible tree row
if cy+step >= maxTreeRows { return nil } // maxTreeRows tracked by the view

Try / catch

// in keybinding handlers: empty-line errors are benign boundaries
if err := CursorStep(g, v, step); err != nil && !strings.Contains(err.Error(), "empty line") {
    return err
}
return nil

Prevention

When it happens

Trigger: Pressing j/down (or k/up past data) when the cursor is on the last file-tree row: v.Line(cy+step) returns an empty string for the blank row below, so the move is rejected. Also occurs with page-step keybindings that jump further than the remaining rows.

Common situations: Navigating a small image's file tree (few entries in the view), or after applying a file filter that shrinks the tree to fewer rows than the cursor's current position+step.

Related errors


AI-assisted analysis of wagoodman/dive@d6c691947f (2026-08-15). Data as JSON: /api/errors/cd09b0fdf799e104. Report an issue: GitHub.