{"record":{"id":"173686efa3f77ddc","repo":"zed-industries/zed","slug":"prefixes-is-non-empty","errorCode":null,"errorMessage":"prefixes is non-empty","messagePattern":"prefixes is non-empty","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/editor/src/input.rs","lineNumber":1544,"sourceCode":"                    continue;\n                }\n\n                // If the language has line comments, toggle those.\n                let mut full_comment_prefixes = language.line_comment_prefixes().to_vec();\n\n                // If ignore_indent is set, trim spaces from the right side of all full_comment_prefixes\n                if ignore_indent {\n                    full_comment_prefixes = full_comment_prefixes\n                        .into_iter()\n                        .map(|s| Arc::from(s.trim_end()))\n                        .collect();\n                }\n\n                if !full_comment_prefixes.is_empty() {\n                    let first_prefix = full_comment_prefixes\n                        .first()\n                        .expect(\"prefixes is non-empty\");\n                    let prefix_trimmed_lengths = full_comment_prefixes\n                        .iter()\n                        .map(|p| p.trim_end_matches(' ').len())\n                        .collect::<SmallVec<[usize; 4]>>();\n\n                    let mut commented_lines = 0;\n                    let mut uncommented_lines = 0;\n\n                    for row in start_row.0..=end_row.0 {\n                        let row = MultiBufferRow(row);\n                        let is_blank = start_row < end_row && snapshot.is_line_blank(row);\n                        if !comment_empty_lines && is_blank {\n                            continue;\n                        }\n\n                        let prefix_range = full_comment_prefixes\n                            .iter()\n                            .zip(prefix_trimmed_lengths.iter().copied())\n                            .map(|(prefix, trimmed_prefix_len)| {","sourceCodeStart":1526,"sourceCodeEnd":1562,"githubUrl":"https://github.com/zed-industries/zed/blob/9d272b036335401f339d024ea94968fd51016c40/crates/editor/src/input.rs#L1526-L1562","documentation":"A precondition guard in toggle_comments: the code took language.line_comment_prefixes() (possibly trimmed for ignore_indent) and later expects the resulting prefix collection to be non-empty before inserting comment tokens. It fires when toggle_comments proceeds on a language that (after trimming) yields zero comment prefixes — the caller should have bailed before reaching the insertion step.","triggerScenarios":"Thrown at crates/editor/src/input.rs:1542 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check full_comment_prefixes.is_empty() after collection/trimming and return early (or fall through to block-comment handling)","Fall back to the language's block comment syntax when line prefixes are empty","Guard at the action level: disable the toggle comments action for languages without any comment tokens"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9d272b036335401f339d024ea94968fd51016c40","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}