micro-editor/micro · warning
no diff data
Error message
no diff data
What it means
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'.
Source
Thrown at internal/buffer/buffer.go:1434
} else {
b.diffBaseLineCount = strings.Count(string(diffBase), "\n")
}
b.UpdateDiff()
}
// DiffStatus returns the diff status for a line in the buffer
func (b *Buffer) DiffStatus(lineN int) DiffStatus {
b.diffLock.RLock()
defer b.diffLock.RUnlock()
// Note that the zero value for DiffStatus is equal to DSUnchanged
return b.diff[lineN]
}
// FindNextDiffLine returns the line number of the next block of diffs.
// If `startLine` is already in a block of diffs, lines in that block are skipped.
func (b *Buffer) FindNextDiffLine(startLine int, forward bool) (int, error) {
if b.diff == nil {
return 0, errors.New("no diff data")
}
startStatus, ok := b.diff[startLine]
if !ok {
startStatus = DSUnchanged
}
curLine := startLine
for {
curStatus, ok := b.diff[curLine]
if !ok {
curStatus = DSUnchanged
}
if curLine < 0 || curLine > b.LinesNum() {
return 0, errors.New("no next diff hunk")
}
if curStatus != startStatus {
if startStatus != DSUnchanged && curStatus == DSUnchanged {
// Skip over the block of unchanged text
startStatus = DSUnchangedView on GitHub (pinned to 1c8b82b32e)
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
Example fix
// before
h.Buf.FindNextDiffLine(cur, true) // -> no diff data
// after
h.DoCommand("diff")
dl, err := h.Buf.FindNextDiffLine(cur, true) Defensive patterns
Strategy: validation
Validate before calling
// Establish diff state before navigating hunks
cur := h.Buf.GetActiveCursor().Y
if h.Buf.DiffStatus(cur) == buffer.DSUnchanged {
// can't distinguish 'no diff yet' from 'unchanged line' — so ensure the
// diff command ran for this buffer before exposing Next/PrevDiff keys
h.DoCommand("diff")
}
dl, err := h.Buf.FindNextDiffLine(cur, true) Try / catch
dl, err := h.Buf.FindNextDiffLine(cur, true)
if err != nil {
if err.Error() == "no diff data" {
InfoBar.Message("run > diff first")
return // sequence error, not fatal
}
InfoBar.Error(err)
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: Keybindings copied from a diff-heavy workflow; plugins calling FindNextDiffLine directly; users expecting automatic git-diff like gutter plugins in other editors.
Related errors
- no next diff hunk
- Not enough arguments
- Error: %s is a directory and cannot be opened
- Error: %s is not a regular file and cannot be opened
- could not open file
AI-assisted analysis of micro-editor/micro@1c8b82b32e (2026-08-15).
Data as JSON: /api/errors/ddcd8d338c3e2604.
Report an issue: GitHub.