MCPcopy Create free account
hub / github.com/GCWing/BitFun / select_current_option

Method select_current_option

src/apps/cli/src/ui/question.rs:391–420  ·  view source on GitHub ↗

Select or toggle the currently highlighted option

(&mut self)

Source from the content-addressed store, hash-verified

389
390 /// Select or toggle the currently highlighted option
391 fn select_current_option(&mut self) -> QuestionAction {
392 if self.is_other_selected() {
393 // Enter editing mode for custom input
394 self.editing_custom = true;
395 return QuestionAction::None;
396 }
397
398 let q = &self.questions[self.current_tab];
399 let opt_label = q.options[self.selected_option].label.clone();
400
401 if q.multi_select {
402 // Toggle
403 let answers = &mut self.answers[self.current_tab];
404 if let Some(pos) = answers.iter().position(|a| a == &opt_label) {
405 answers.remove(pos);
406 } else {
407 answers.push(opt_label);
408 }
409 QuestionAction::None
410 } else {
411 // Single-select: pick and advance
412 self.answers[self.current_tab] = vec![opt_label];
413 if self.is_single_auto_submit() {
414 QuestionAction::Submit(self.build_answers_payload())
415 } else {
416 self.advance_tab();
417 QuestionAction::None
418 }
419 }
420 }
421
422 /// Advance to the next tab
423 fn advance_tab(&mut self) {

Callers 1

handle_question_keyMethod · 0.80

Calls 8

is_other_selectedMethod · 0.80
iterMethod · 0.80
is_single_auto_submitMethod · 0.80
build_answers_payloadMethod · 0.80
advance_tabMethod · 0.80
cloneMethod · 0.45
removeMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected