Avoid ICE when suggestion span is at Eof

This commit is contained in:
Esteban Küber 2019-07-25 15:59:38 -07:00
parent 03f19f7ff1
commit eeb1bd18dc
3 changed files with 71 additions and 1 deletions

View file

@ -229,7 +229,8 @@ impl CodeSuggestion {
}
}
if let Some(cur_line) = fm.get_line(cur_lo.line - 1) {
buf.push_str(&cur_line[..cur_lo.col.to_usize()]);
let end = std::cmp::min(cur_line.len(), cur_lo.col.to_usize());
buf.push_str(&cur_line[..end]);
}
}
buf.push_str(&part.snippet);