slint-ui/slint · error

This is not loading anything!

Error message

This is not loading anything!

What it means

In `edited_text_compiles` (used by drag-and-drop compilation checks), the code takes a snapshot of the shared `DocumentCache` via `document_cache.snapshot().expect("This is not loading anything!")`. The snapshot is an `Option` that is None only while the cache is in a loading/inconsistent state; the function assumes it is only ever called with a fully loaded cache, and panics otherwise.

Solutions

  1. Retry the drop/edit action after the project has finished loading (wait for the LSP to report the document as loaded/compiled).
  2. Ensure all workspace documents compile and are opened before using preview drag-and-drop features.
  3. Update slint-lsp/slintpad — races between cache loading and drop handling may be fixed in newer versions.
  4. As a code fix, return `preview::CompilationResult::Failed` (or NoChange) when `snapshot()` is None instead of panicking.

Example fix

// before
let mut document_cache = document_cache.snapshot().expect("This is not loading anything!");

// after
let Some(mut document_cache) = document_cache.snapshot() else {
    return preview::CompilationResult::NoChange; // cache still loading
};
Defensive patterns

Strategy: type-guard

Validate before calling

// guard before drop-based edits
if !document_cache.is_loaded() { return preview::CompilationResult::NoChange; }

Type guard

let Some(snapshot) = document_cache.snapshot() else { return preview::CompilationResult::NoChange; };

Try / catch

// call sites can treat drops during loading as no-ops
match edited_text_compiles(&document_cache, edits) {
    r => r,
    // panic only escapes if cache was mid-load; serialize drops until loaded
}

Prevention

When it happens

Trigger: A workspace/drop edit compilation (`workspace_edit_compiles` -> `edited_text_compiles`) is invoked while the DocumentCache is still loading documents (e.g. during initial project load, mid-reload after a file change, or after a previous failed load left the cache without a snapshot).

Common situations: Dragging a widget/file into the preview window at the exact moment the LSP is (re)loading the project; rapid open-and-drop sequences where the drop handler races the initial compilation; a document that failed to load leaving the cache snapshot-less.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of slint-ui/slint@bb937076de (2026-09-16). Data as JSON: /api/errors/2c4ccc1982be69fb. Report an issue: GitHub.

Appendix: source

Thrown at tools/lsp/preview/drop_location.rs:837

    workspace_edit: &lsp_types::WorkspaceEdit,
) -> preview::CompilationResult {
    let Ok(result) = text_edit::apply_workspace_edit(document_cache, workspace_edit) else {
        return preview::CompilationResult::ChangeFails;
    };
    edited_text_compiles(document_cache, result)
}

pub fn edited_text_compiles(
    document_cache: &editor_preview::DocumentCache,
    mut result: Vec<text_edit::EditedText>,
) -> preview::CompilationResult {
    if result.is_empty() {
        return preview::CompilationResult::NoChange;
    }

    let mut diag = BuildDiagnostics::default();

    let mut document_cache = document_cache.snapshot().expect("This is not loading anything!");

    // Fill in changed sources:
    for (u, c) in result.drain(..).map(|mut r| {
        let contents = std::mem::take(&mut r.contents);
        (r.url.clone(), contents)
    }) {
        diag = BuildDiagnostics::default(); // reset errors that might be due to missing changes elsewhere

        let _ = editor_preview::util::poll_once(document_cache.load_url(&u, None, c, &mut diag));
    }

    if diag.has_errors() {
        preview::CompilationResult::ChangeFails
    } else {
        preview::CompilationResult::ChangeCompiles
    }
}

View on GitHub (pinned to bb937076de)