Skip to main content

action_mutates_fold_state

Function action_mutates_fold_state 

Source
pub fn action_mutates_fold_state(action: &Action) -> bool
Expand description

Returns true for actions that mutate the document and therefore must no-op when a read-only help buffer holds focus.

Motions and scroll-class actions are NOT in this set – they operate on whichever buffer is active (document or help) per the per-action active-buffer routing. The read-only-help guard in [handle_action] short-circuits these when active_buffer == Help so a stray i / p / u / dd while reading help Does action change the buffer’s FOLD state?

Folding writes nothing, so this is not a read-only concern. It exists for the one place fold state is genuinely unsafe: self.folds is keyed to document_buffer_id and is not swapped when a popup takes focus, so a fold chord pressed at a focused popup edits the folds of the buffer behind it (PIC.2). Refusing it there is a guard on that aliasing, not on writability.

The real fix is to key fold state to the focused buffer; until then this keeps the damage out without pretending a fold is an edit.