Docs

api-lines

Source: crates/lvcs-api/src/lines.rs.

/// A range as a reader is shown it (decisions 156 and 160).
///
/// `first` and `last` are the 1-based numbers of its first and last lines in
/// the text it was named in, inclusive. `near` is git's default hunk-header
/// line, taken at or above `first`: the nearest line whose first character
/// is an ASCII letter, `_`, or `$`, without its newline and trailing
/// whitespace, cut to `RANGE_CONTEXT_MAX_CHARS` code points. It is a
/// heuristic line, never a parse, so it can name a line outside the
/// enclosing definition. `Display` writes `line 40` or `lines 40\u{2013}52`,
/// then `, near "<near>"` when there is one; a surface that doesn't already
/// name the file puts the path first.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct LineName {
    /// The range's first line, 1-based.
    pub first: usize,
    /// Its last line, 1-based and inclusive.
    pub last: usize,
    /// The hunk-header line at or above `first`, if any.
    pub near: Option<String>,
}