Closed Cyrix126 closed 9 months ago
The DEFAULT_RESET_CURSOR
was set by default to true
to prevent any "behaviour" and when the function run_scorer is called it verifies the reset_cursor flag and that's why it puts it on default 0 every time.
fn run_scorer(&mut self) {
let mut options = self.score_options();
options.sort_unstable_by_key(|(_idx, score)| Reverse(*score));
self.scored_options = options.into_iter().map(|(idx, _)| idx).collect();
if self.config.reset_cursor {
let _ = self.update_cursor_position(0);
} else if self.scored_options.len() <= self.cursor_index {
let _ = self.update_cursor_position(self.scored_options.len().saturating_sub(1));
}
}
Thanks for the report! I'm pushing a fix and also adding a test so this regression doesn't happen again
Describe the bug When using the method with_starting_cursor on a Select prompt, it doesn't start with the cursor on the custom index but goes on the default one (the first).
To Reproduce Steps to reproduce the behavior:
fn main() { let options = vec![ "Banana", "Apple", "Strawberry", "Grapes", "Lemon", "Tangerine", "Watermelon", "Orange", "Pear", "Avocado", "Pineapple", ];
}
cargo run --example select