Fix underflow potential

Mikayla Maki created

Change summary

crates/editor/src/editor.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

Detailed changes

crates/editor/src/editor.rs 🔗

@@ -1079,7 +1079,7 @@ impl CopilotState {
         match direction {
             Direction::Prev => {
                 self.active_completion_index = if self.active_completion_index == 0 {
-                    self.completions.len() - 1
+                    self.completions.len().saturating_sub(1)
                 } else {
                     self.active_completion_index - 1
                 };