fn get_position_idx()

in crates/llm-ls/src/main.rs [38:46]


fn get_position_idx(rope: &Rope, row: usize, col: usize) -> Result<usize> {
    Ok(rope.try_line_to_char(row)?
        + col.min(
            rope.get_line(row.min(rope.len_lines().saturating_sub(1)))
                .ok_or(Error::OutOfBoundLine(row, rope.len_lines()))?
                .len_chars()
                .saturating_sub(1),
        ))
}