Skip to main content

sync_rebuild_pane_on_edit

Function sync_rebuild_pane_on_edit 

Source
pub fn sync_rebuild_pane_on_edit(
    pane: &PaneCellsInputs,
    ct: CellTheme<'_>,
    whitespace: &WhitespaceConfig,
) -> bool
Expand description

B2.3 (2026-06-04): the synchronous, edit-path-only DisplayMatrix rebuild the actor runs in the publish tail (crate::dispatch’s publish_render_state) before the render state is stored, so the published display_matrix is text-current the instant the renderer paints — version.text never lags the snapshot, which is what retires the per-keystroke whole-viewport stale-guard flicker.

Honours the B2 threading guarantee (CLAUDE.md / the slice plan): the edit-critical thread does ONLY O(window) text + structure work — prefix/suffix DisplayLine Arc-reuse plus the edited line(s)’ text rebuild — and never a highlight_lines call, reparse, or full O(file) build. Concretely it attempts ONLY [try_incremental_display_build] with allow_highlight: false:

  • Eligible (single text edit, unchanged inlay/fold/theme axes, line-count consistent, stable chunk shape, result still covers the viewport) → store the rebuilt matrix into pane.display_matrix and return true. The edited line shows default fg until the async worker recolours it; unchanged lines keep their colour via Arc reuse.
  • Ineligible (non-edit publish, doc switch, chunk-shape change, same-tick window miss) → leave pane.display_matrix untouched and return false. The async worker performs the full / highlighted build off-thread.

Deliberately does NOT project to the cell grid: that O(window) projection stays on the async worker (recompute_pane reconciles the lagging cells on its next wake). Cells therefore trail the display matrix by one worker tick until the renderers cut over to DisplayMatrix (TUI B2.4, GPU B3) and the cell path is deleted (B4).