{"record":{"id":"ddcd8d338c3e2604","repo":"micro-editor/micro","slug":"no-diff-data","errorCode":null,"errorMessage":"no diff data","messagePattern":"no diff data","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/buffer/buffer.go","lineNumber":1434,"sourceCode":"\t} else {\n\t\tb.diffBaseLineCount = strings.Count(string(diffBase), \"\\n\")\n\t}\n\tb.UpdateDiff()\n}\n\n// DiffStatus returns the diff status for a line in the buffer\nfunc (b *Buffer) DiffStatus(lineN int) DiffStatus {\n\tb.diffLock.RLock()\n\tdefer b.diffLock.RUnlock()\n\t// Note that the zero value for DiffStatus is equal to DSUnchanged\n\treturn b.diff[lineN]\n}\n\n// FindNextDiffLine returns the line number of the next block of diffs.\n// If `startLine` is already in a block of diffs, lines in that block are skipped.\nfunc (b *Buffer) FindNextDiffLine(startLine int, forward bool) (int, error) {\n\tif b.diff == nil {\n\t\treturn 0, errors.New(\"no diff data\")\n\t}\n\tstartStatus, ok := b.diff[startLine]\n\tif !ok {\n\t\tstartStatus = DSUnchanged\n\t}\n\tcurLine := startLine\n\tfor {\n\t\tcurStatus, ok := b.diff[curLine]\n\t\tif !ok {\n\t\t\tcurStatus = DSUnchanged\n\t\t}\n\t\tif curLine < 0 || curLine > b.LinesNum() {\n\t\t\treturn 0, errors.New(\"no next diff hunk\")\n\t\t}\n\t\tif curStatus != startStatus {\n\t\t\tif startStatus != DSUnchanged && curStatus == DSUnchanged {\n\t\t\t\t// Skip over the block of unchanged text\n\t\t\t\tstartStatus = DSUnchanged","sourceCodeStart":1416,"sourceCodeEnd":1452,"githubUrl":"https://github.com/micro-editor/micro/blob/1c8b82b32e408a5faf340039ed92d5266bea3293/internal/buffer/buffer.go#L1416-L1452","documentation":"Returned by (*Buffer).FindNextDiffLine (internal/buffer/buffer.go:1434) when b.diff is nil — the buffer has no diff state yet. Diff data is only populated after a diff has been computed against the file's git history (the > diff command / diff gutter feature). Calling NextDiff/PrevDiff (internal/action/actions.go:1279/1290) before that is a sequence error: 'compute a diff first'.","triggerScenarios":"Opening a file and immediately invoking the NextDiff or PrevDiff action (default bindings on Ctrl-n/Ctrl-p family in diff mode) without ever running > diff; the diff buffer state was reset after a reload or after switching buffers in the same tab.","commonSituations":"Keybindings copied from a diff-heavy workflow; plugins calling FindNextDiffLine directly; users expecting automatic git-diff like gutter plugins in other editors.","solutions":["Run > diff first; afterwards NextDiff/PrevDiff have data to walk","Confirm the file lives inside a git work tree — with no VCS info there is never diff data","In code, ensure the diff was requested (b.diff != nil equivalent) before navigating; see validation snippet for the caller-side ordering"],"exampleFix":"// before\nh.Buf.FindNextDiffLine(cur, true) // -> no diff data\n\n// after\nh.DoCommand(\"diff\")\ndl, err := h.Buf.FindNextDiffLine(cur, true)","handlingStrategy":"validation","validationCode":"// Establish diff state before navigating hunks\ncur := h.Buf.GetActiveCursor().Y\nif h.Buf.DiffStatus(cur) == buffer.DSUnchanged {\n    // can't distinguish 'no diff yet' from 'unchanged line' — so ensure the\n    // diff command ran for this buffer before exposing Next/PrevDiff keys\n    h.DoCommand(\"diff\")\n}\ndl, err := h.Buf.FindNextDiffLine(cur, true)","typeGuard":null,"tryCatchPattern":"dl, err := h.Buf.FindNextDiffLine(cur, true)\nif err != nil {\n    if err.Error() == \"no diff data\" {\n        InfoBar.Message(\"run > diff first\")\n        return // sequence error, not fatal\n    }\n    InfoBar.Error(err)\n}","preventionTips":["Always run > diff once after opening a git-tracked file before using diff navigation","Bind Next/PrevDiff only in workflows that start with a diff","Remember reloading the buffer can clear diff state — re-run > diff after reload"],"tags":["diff","git","navigation","sequence","buffer"],"backgroundTag":null,"analyzedSha":"1c8b82b32e408a5faf340039ed92d5266bea3293","analyzedAt":"2026-08-15T20:01:45.134Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}