diff options
author | Philipp Mildenberger | 2023-06-12 16:37:47 +0000 |
---|---|---|
committer | GitHub | 2023-06-12 16:37:47 +0000 |
commit | 2a11fb485d33eb33a7743899e9a86f745f6d5e02 (patch) | |
tree | 0bad99be0f34f74f6aa79c2a809c00f74d93d5fb /helix-term | |
parent | 25ad534d6404e2aa39536df818371dcbbc928b52 (diff) |
Fix underflow when repeating a completion that has a negative shift position (#7322)
Diffstat (limited to 'helix-term')
-rw-r--r-- | helix-term/src/ui/editor.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index 4f7916ff..16940e33 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -907,8 +907,9 @@ impl EditorView { 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(), |