zed-industries/zed · error

editor does not have project

Error message

editor does not have project

What it means

The editor performing a git operation has no associated project entity. The surrounding code needs workspace.project() to look up diffs/baselines; this guard fires when the editor was created detached from any workspace project, so the git interaction cannot proceed.

Source

Thrown at crates/editor/src/git.rs:2926

            let Some(buffer_diff) = multi_buffer.diff_for(buffer_snapshot.remote_id()) else {
                return Some((buffer, buffer_range.start.row..buffer_range.end.row));
            };

            let buffer_diff_snapshot = buffer_diff.read(cx).snapshot(cx);
            let start = buffer_diff_snapshot
                .buffer_point_to_base_text_point(buffer_range.start, &buffer_snapshot);
            let end = buffer_diff_snapshot
                .buffer_point_to_base_text_point(buffer_range.end, &buffer_snapshot);

            Some((buffer, start.row..end.row))
        });

        let Some((buffer, selection)) = buffer_and_selection else {
            return Task::ready(Err(anyhow!("failed to determine buffer and selection")));
        };

        let Some(project) = self.project() else {
            return Task::ready(Err(anyhow!("editor does not have project")));
        };

        project.update(cx, |project, cx| {
            project.get_permalink_to_line(&buffer, selection, cx)
        })
    }
}

#[cfg(test)]
impl Editor {
    /// Returns the line range for the first diff review overlay, if one is active.
    /// Returns (start_row, end_row) as physical line numbers in the underlying file.
    pub(super) fn diff_review_line_range(&self, cx: &App) -> Option<(u32, u32)> {
        let overlay = self.diff_review_overlays.first()?;
        let snapshot = self.buffer.read(cx).snapshot(cx);
        let start_point = overlay.anchor_range.start.to_point(&snapshot);
        let end_point = overlay.anchor_range.end.to_point(&snapshot);
        let start_row = snapshot

View on GitHub (pinned to f4178619ac)

Solutions

  1. No-op the git action when the editor has no project — there is nothing to diff against
  2. Ensure editors are constructed within a workspace so the project handle is always available
  3. Fall back to a shell git invocation in the file's directory if a project is genuinely absent
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at crates/editor/src/git.rs:2926 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20). Data as JSON: /api/errors/2703e7c6820f9d23. Report an issue: GitHub.