{"record":{"id":"2c4ccc1982be69fb","repo":"slint-ui/slint","slug":"this-is-not-loading-anything","errorCode":null,"errorMessage":"This is not loading anything!","messagePattern":"This is not loading anything!","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tools/lsp/preview/drop_location.rs","lineNumber":837,"sourceCode":"    workspace_edit: &lsp_types::WorkspaceEdit,\n) -> preview::CompilationResult {\n    let Ok(result) = text_edit::apply_workspace_edit(document_cache, workspace_edit) else {\n        return preview::CompilationResult::ChangeFails;\n    };\n    edited_text_compiles(document_cache, result)\n}\n\npub fn edited_text_compiles(\n    document_cache: &editor_preview::DocumentCache,\n    mut result: Vec<text_edit::EditedText>,\n) -> preview::CompilationResult {\n    if result.is_empty() {\n        return preview::CompilationResult::NoChange;\n    }\n\n    let mut diag = BuildDiagnostics::default();\n\n    let mut document_cache = document_cache.snapshot().expect(\"This is not loading anything!\");\n\n    // Fill in changed sources:\n    for (u, c) in result.drain(..).map(|mut r| {\n        let contents = std::mem::take(&mut r.contents);\n        (r.url.clone(), contents)\n    }) {\n        diag = BuildDiagnostics::default(); // reset errors that might be due to missing changes elsewhere\n\n        let _ = editor_preview::util::poll_once(document_cache.load_url(&u, None, c, &mut diag));\n    }\n\n    if diag.has_errors() {\n        preview::CompilationResult::ChangeFails\n    } else {\n        preview::CompilationResult::ChangeCompiles\n    }\n}\n","sourceCodeStart":819,"sourceCodeEnd":855,"githubUrl":"https://github.com/slint-ui/slint/blob/bb937076de3f7919766c1f25e2e969367cf77e9a/tools/lsp/preview/drop_location.rs#L819-L855","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Retry the drop/edit action after the project has finished loading (wait for the LSP to report the document as loaded/compiled).","Ensure all workspace documents compile and are opened before using preview drag-and-drop features.","Update slint-lsp/slintpad — races between cache loading and drop handling may be fixed in newer versions.","As a code fix, return `preview::CompilationResult::Failed` (or NoChange) when `snapshot()` is None instead of panicking."],"exampleFix":"// before\nlet mut document_cache = document_cache.snapshot().expect(\"This is not loading anything!\");\n\n// after\nlet Some(mut document_cache) = document_cache.snapshot() else {\n    return preview::CompilationResult::NoChange; // cache still loading\n};","handlingStrategy":"type-guard","validationCode":"// guard before drop-based edits\nif !document_cache.is_loaded() { return preview::CompilationResult::NoChange; }","typeGuard":"let Some(snapshot) = document_cache.snapshot() else { return preview::CompilationResult::NoChange; };","tryCatchPattern":"// call sites can treat drops during loading as no-ops\nmatch edited_text_compiles(&document_cache, edits) {\n    r => r,\n    // panic only escapes if cache was mid-load; serialize drops until loaded\n}","preventionTips":["Wait for the initial project compilation to finish before using preview drag-and-drop.","Avoid rapid open-then-drop sequences that race the DocumentCache loader.","Ensure all workspace documents load successfully; a failed load can leave no snapshot.","Patch snapshot() consumers to degrade gracefully (NoChange/Failed) instead of panicking."],"tags":["lsp","preview","document-cache","panic","race-condition"],"backgroundTag":"internal-invariant-violation","analyzedSha":"bb937076de3f7919766c1f25e2e969367cf77e9a","analyzedAt":"2026-09-16T01:37:20.251Z","contentChangedAt":"2026-09-16T01:37:20.251Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}