Fix MetricsDashboard::selected_index() to return Option<usize>#115
Open
ryanoneill wants to merge 1 commit intomainfrom
Open
Fix MetricsDashboard::selected_index() to return Option<usize>#115ryanoneill wants to merge 1 commit intomainfrom
ryanoneill wants to merge 1 commit intomainfrom
Conversation
Change the internal selected field from usize to Option<usize> so that an empty dashboard correctly reports no selection (None) instead of returning 0 pointing to nothing. - Change selected field from usize to Option<usize> - Default state uses None, new() uses Some(0) when widgets exist - selected_index() now returns Option<usize> - selected_position() now returns Option<(usize, usize)> - Update all navigation logic to wrap/unwrap Option - Update view() to use Option comparison - Update all test assertions to expect Some(value) - Add test_empty_dashboard_selected_index_is_none test Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #115 +/- ##
=======================================
Coverage 92.61% 92.61%
=======================================
Files 100 100
Lines 9530 9534 +4
=======================================
+ Hits 8826 8830 +4
Misses 704 704 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
selectedfield fromusizetoOption<usize>for correctnessselected_index()now returnsOption<usize>(wasusize)selected_position()now returnsOption<(usize, usize)>(was(usize, usize))Noneinstead of0pointing to nothingContext
All other Envision components return
Option<usize>from their index methods. MetricsDashboard was the outlier returning a bareusize. When the widgets vec was empty,selected_index()returned0which was misleading.Test plan
test_empty_dashboard_selected_index_is_nonecovers the empty casecargo clippy --all-targets --all-features -- -D warningsclean🤖 Generated with Claude Code