fix(tui): bounds-check scope picker selected index
Replace direct indexing (self.projects[self.selected_index - 1]) with .get() to prevent panic if selected_index is somehow out of bounds. Falls back to "All Projects" scope when the index is invalid instead of panicking.
This commit is contained in:
@@ -76,12 +76,17 @@ impl ScopePickerState {
|
||||
project_id: None,
|
||||
project_name: None,
|
||||
}
|
||||
} else {
|
||||
let project = &self.projects[self.selected_index - 1];
|
||||
} else if let Some(project) = self.projects.get(self.selected_index - 1) {
|
||||
ScopeContext {
|
||||
project_id: Some(project.id),
|
||||
project_name: Some(project.path.clone()),
|
||||
}
|
||||
} else {
|
||||
// Out-of-bounds — fall back to "All Projects".
|
||||
ScopeContext {
|
||||
project_id: None,
|
||||
project_name: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user