gitbutlerapp/gitbutler · critical

line should have been highlighted by now

Error message

line should have been highlighted by now

What it means

A developer panic (`.expect`) in the TUI details renderer: by the time `render_details_line` draws a line, an earlier background pass should have populated `line.syntax_highlighted_line`. If it is still `None`, the invariant 'every rendered line was highlighted' is broken and the app panics with this message instead of rendering unhighlighted text.

Solutions

  1. Report it as a bug — this is an internal invariant violation, not user error.
  2. Work around by scrolling away from the affected region or resizing the terminal to force a redraw.
  3. Update GitButler; check for a fixed version referencing this panic.
  4. If reproducible, capture the file type and diff state that triggers it and file an issue.

Example fix

// before
let line = syntax_highlighted_line.as_ref().expect("line should have been highlighted by now");
// after
let Some(line) = syntax_highlighted_line.as_ref() else {
    strings.push(Line::raw(raw_line));
    return;
};
Defensive patterns

Strategy: fallback

Prevention

When it happens

Trigger: Rendering a details/diff line whose syntax highlighting task never ran or never completed before the draw, e.g. a line added to the list after the highlighting pass, or the highlight computation was skipped/failed for that line.

Common situations: Rapidly scrolling or resizing so new lines are drawn before highlighting catches up; a syntax-highlighting failure for an unusual file type; races between the async highlighter and the render loop on freshly loaded diffs.

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 gitbutlerapp/gitbutler@58e5313667 (2026-09-18). Data as JSON: /api/errors/0781b5c6fa41bffe. Report an issue: GitHub.

Appendix: source

Thrown at crates/but/src/command/legacy/status/tui/details.rs:1034

                    if highlight_lines.is_none() {
                        let syntax = line.syntax(syntax_set);
                        *highlight_lines = Some(HighlightLines::new(syntax, syntax_theme));
                    }

                    let id = line.id;
                    let mut strings = self.strings.lock();

                    line.ensure_highlighted(
                        syntax_set,
                        highlight_lines.as_mut().unwrap(),
                        self.theme,
                        &mut strings,
                    );

                    let syntax_highlighted_line = line.syntax_highlighted_line.borrow();
                    let syntax_highlighted_line = syntax_highlighted_line
                        .as_ref()
                        .expect("line should have been highlighted by now");

                    if self.section_is_to_be_discarded(id) {
                        let crossed_out_line = syntax_highlighted_line
                            .spans
                            .iter()
                            .cloned()
                            .map(|span| span.crossed_out())
                            .collect::<Line<'_>>()
                            .style(syntax_highlighted_line.style);
                        frame.render_widget(crossed_out_line, line_area);
                    } else {
                        frame.render_widget(syntax_highlighted_line, line_area);
                    }

                    if line
                        .cli_id
                        .as_ref()
                        .is_some_and(|id| marks.contains_cli_id(id))

View on GitHub (pinned to 58e5313667)