Skip to main content

gutter_cols

Function gutter_cols 

Source
pub fn gutter_cols(
    line_count: u32,
    show_line_numbers: bool,
    sign_column: bool,
) -> u32
Expand description

Non-body columns a document pane reserves for its gutter: line-number column + diagnostic + diff-sign cells. Mirrors the TUI renderer’s gutter_width + DIAG + DIFF (lattice-ui-tui:: render) and the GPUI peer’s gutter, reducing to digits + 5 with line numbers on (leading pad 1 + digits + trailing pad 2 + DIAG 1 + DIFF 1) or a bare 4 with them off (2-cell margin + DIAG 1 + DIFF 1).

SINGLE SOURCE OF TRUTH shared with [crate::editor::Editor:: body_text_width]. The soft-wrap width the worker stamps on the matrix (wrap_width, read by segment_count — the vertical scroll clamp’s display-row model — AND by both renderers’ paint paths) MUST equal the width the renderer wraps body text at, or G/bottom_anchored_scroll under-counts wrapped rows and clips the document tail (the recurring “last lines off-screen” bug). Because the horizontal clamp already derives its body width the same way, keeping both on this one function is what prevents the two clamps from drifting again.