diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index 4f7916ffd..16940e337 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -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(),