Skip to main content

line_before_cursor

Function line_before_cursor 

Source
pub fn line_before_cursor(buffer: &Buffer, cursor: Position) -> String
Expand description

The text from the start of cursor’s line up to cursor.

Public because the host builds an InsertContextSnapshot directly in one place (the async fan-out) rather than through InsertContextSnapshot::from_context, and the two must agree — a second hand-rolled slice is how they would drift.

Byte-clamped rather than trusting cursor.byte: an out-of-range cursor yields the whole line (or "" for a missing line), never a panic on a completion path.