Fix panic on paste when editing with auto-indent

Instead of accepting text as it's input by the user, we will read it
out of the edit operation after it gets sanitized by the buffer.
This commit is contained in:
Antonio Scandurra 2022-07-06 19:00:11 +02:00
parent 573dd29882
commit d3db700db4
2 changed files with 25 additions and 1 deletions

View file

@ -1233,7 +1233,8 @@ impl Buffer {
let inserted_ranges = edits
.into_iter()
.filter_map(|(range, new_text)| {
.zip(&edit_operation.as_edit().unwrap().new_text)
.filter_map(|((range, _), new_text)| {
let first_newline_ix = new_text.find('\n')?;
let new_text_len = new_text.len();
let start = (delta + range.start as isize) as usize + first_newline_ix + 1;