Fix underflow when repeating a completion that has a negative shift position (#7322)

This commit is contained in:
Philipp Mildenberger 2023-06-12 18:37:47 +02:00 committed by GitHub
parent 25ad534d64
commit 2a11fb485d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -907,8 +907,9 @@ fn command_mode(&mut self, mode: Mode, cxt: &mut commands::Context, event: KeyEv
let text = doc.text().slice(..);
let cursor = doc.selection(view.id).primary().cursor(text);
let shift_position =
|pos: usize| -> usize { pos + cursor - trigger_offset };
let shift_position = |pos: usize| -> usize {
(pos + cursor).saturating_sub(trigger_offset)
};
let tx = Transaction::change(
doc.text(),