Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Fix underflow potential

Mikayla Makice8442a3d84a
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs
index f6fc89de2f7..742541293e9 100644
--- a/crates/editor/src/editor.rs
+++ b/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
};