{"record":{"id":"cd09b0fdf799e104","repo":"wagoodman/dive","slug":"unable-to-move-the-cursor-empty-line","errorCode":null,"errorMessage":"unable to move the cursor, empty line","messagePattern":"unable to move the cursor, empty line","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"cmd/dive/cli/internal/ui/v1/view/cursor.go","lineNumber":29,"sourceCode":"\treturn CursorStep(g, v, 1)\n}\n\n// CursorUp moves the cursor up in the currently selected gocui pane, scrolling the screen as needed.\nfunc CursorUp(g *gocui.Gui, v *gocui.View) error {\n\treturn CursorStep(g, v, -1)\n}\n\n// Moves the cursor the given step distance, setting the origin to the new cursor line\nfunc CursorStep(g *gocui.Gui, v *gocui.View, step int) error {\n\tcx, cy := v.Cursor()\n\n\t// if there isn't a next line\n\tline, err := v.Line(cy + step)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif len(line) == 0 {\n\t\treturn errors.New(\"unable to move the cursor, empty line\")\n\t}\n\tif err := v.SetCursor(cx, cy+step); err != nil {\n\t\tox, oy := v.Origin()\n\t\tif err := v.SetOrigin(ox, oy+step); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}\n","sourceCodeStart":11,"sourceCodeEnd":39,"githubUrl":"https://github.com/wagoodman/dive/blob/d6c691947f8fda635c952a17ee3b7555379d58f0/cmd/dive/cli/internal/ui/v1/view/cursor.go#L11-L39","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["No fix needed for data — this is a soft navigation boundary; simply do not move further in that direction","If it appears mid-tree, check for a custom keybinding with a large step value and reduce it","If a filtered view shows blank rows inside the tree, clear the filter (press / then Escape or the reset key) and retry navigation","Developers patching the UI can treat an empty target line as 'clamp to last valid row' instead of returning an error"],"exampleFix":"// before\nif len(line) == 0 {\n    return errors.New(\"unable to move the cursor, empty line\")\n}\n\n// after (clamp instead of erroring)\nif len(line) == 0 {\n    return nil // at the edge of the tree; ignore the move\n}","handlingStrategy":"validation","validationCode":"// callers of CursorStep: skip moves past the last visible tree row\nif cy+step >= maxTreeRows { return nil } // maxTreeRows tracked by the view","typeGuard":null,"tryCatchPattern":"// in keybinding handlers: empty-line errors are benign boundaries\nif err := CursorStep(g, v, step); err != nil && !strings.Contains(err.Error(), \"empty line\") {\n    return err\n}\nreturn nil","preventionTips":["Treat this error as a no-op boundary condition in keybinding handlers","Track the number of rendered tree rows alongside the view to clamp cursor moves","Avoid oversized step keybindings on small trees"],"tags":["ui","gocui","navigation","tui"],"backgroundTag":null,"analyzedSha":"d6c691947f8fda635c952a17ee3b7555379d58f0","analyzedAt":"2026-08-15T09:42:35.293Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}