fn replace_string_in_range(
    mut contents: String,
    range: lsp::Range,
    new: String,
) -> String {
    let mut string_range: (usize, usize) = (0, 0);
    let lookup = line_col::LineColLookup::new(&contents);
    for i in 0..contents.len() {
        let linecol = lookup.get(i);
        if linecol.0 == (range.start.line as usize) + 1
            && linecol.1 == (range.start.character as usize) + 1
        {
            string_range.0 = i;
        }
        if linecol.0 == (range.end.line as usize) + 1
            && linecol.1 == (range.end.character as usize) + 1
        {
            string_range.1 = i + 1; // Range is not inclusive.
            break;
        }
    }
    if string_range.1 < string_range.0 {
        error!("range end not found after range start");
        return contents;
    }
    contents.replace_range(string_range.0..string_range.1, &new);
    contents
}
/// Take a lsp::Range that contains a start and end lsp::Position, find the
/// indexes of those points in the string, and replace that range with a new string.
Take a lsp::Range that contains a start and end lsp::Position, find the
indexes of those points in the string, and replace that range with a new string.
Take a lsp :: Range that contains a start and end lsp :: Position find the indexes of those points in the string and replace that range with a new string .
fn replace_string_in_range(
    mut contents: String,
    range: lsp::Range,
    new: String,
) -> String {
    let mut string_range: (usize, usize) = (0, 0);
    let lookup = line_col::LineColLookup::new(&contents);
    for i in 0..contents.len() {
        let linecol = lookup.get(i);
        if linecol.0 == (range.start.line as usize) + 1
            && linecol.1 == (range.start.character as usize) + 1
        {
            string_range.0 = i;
        }
        if linecol.0 == (range.end.line as usize) + 1
            && linecol.1 == (range.end.character as usize) + 1
        {
            string_range.1 = i + 1; // Range is not inclusive.
            break;
        }
    }
    if string_range.1 < string_range.0 {
        error!("range end not found after range start");
        return contents;
    }
    contents.replace_range(string_range.0..string_range.1, &new);
    contents
}
fn replace_string_in_range ( mut contents : String , range : lsp :: Range , new : String , ) -> String { let mut string_range : ( usize , usize ) = ( 0 , 0 ) ; let lookup = line_col :: LineColLookup :: new ( & contents ) ; for i in 0 .. contents . len ( ) { let linecol = lookup . get ( i ) ; if linecol . 0 == ( range . start . line as usize ) + 1 && linecol . 1 == ( range . start . character as usize ) + 1 { string_range . 0 = i ; } if linecol . 0 == ( range . end . line as usize ) + 1 && linecol . 1 == ( range . end . character as usize ) + 1 { string_range . 1 = i + 1 ; // Range is not inclusive. break ; } } if string_range . 1 < string_range . 0 { error ! ( " " ) ; return contents ; } contents . replace_range ( string_range . 0 .. string_range . 1 , & new ) ; contents }
Take a lsp::Range that contains a start and end lsp::Position, find the
indexes of those points in the string, and replace that range with a new string.
Take a lsp :: Range that contains a start and end lsp :: Position find the indexes of those points in the string and replace that range with a new string .
contents
String
range
lsp::Range
new
String