Skip to main content

apply

Function apply 

Source
pub fn apply(
    lines: &[&str],
    position: Cursor,
    viewport: &mut Viewport,
    motion: Motion,
) -> Cursor
Expand description

Applies one completed motion and returns the new cursor position.

lines is borrowed and never modified. An empty slice behaves like one empty logical line. The input cursor is clamped to the final line and a valid UTF-8 scalar boundary; counts and coordinates are handled with saturating or content-bounded arithmetic rather than caller-visible errors. The viewport is updated in place to keep the result visible and to retain Vim’s desired display column across vertical movement.

Search and mark variants need histories or resources that this crate does not own. They are intentionally no-ops here and must be applied by a caller adapter, which can then call reveal for the selected location.