Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add inapplicable condition on menu activation and navigation #608

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,14 @@
return Ok(EventStatus::Handled);
}

if self.quick_completions
&& menu.can_quick_complete()
&& menu.get_values().is_empty()

Check warning on line 972 in src/engine.rs

View check run for this annotation

Codecov / codecov/patch

src/engine.rs#L970-L972

Added lines #L970 - L972 were not covered by tests
{
menu.menu_event(MenuEvent::Deactivate);
return Ok(EventStatus::Inapplicable);
}

Check warning on line 977 in src/engine.rs

View check run for this annotation

Codecov / codecov/patch

src/engine.rs#L974-L977

Added lines #L974 - L977 were not covered by tests
return Ok(EventStatus::Handled);
}
}
Expand All @@ -975,41 +983,59 @@
ReedlineEvent::MenuNext => {
self.active_menu()
.map_or(Ok(EventStatus::Inapplicable), |menu| {
if menu.get_values().len() < 2 {
return Ok(EventStatus::Inapplicable);
}

Check warning on line 988 in src/engine.rs

View check run for this annotation

Codecov / codecov/patch

src/engine.rs#L986-L988

Added lines #L986 - L988 were not covered by tests
menu.menu_event(MenuEvent::NextElement);
Ok(EventStatus::Handled)
})
}
ReedlineEvent::MenuPrevious => {
self.active_menu()
.map_or(Ok(EventStatus::Inapplicable), |menu| {
if menu.get_values().len() < 2 {
return Ok(EventStatus::Inapplicable);
}

Check warning on line 998 in src/engine.rs

View check run for this annotation

Codecov / codecov/patch

src/engine.rs#L996-L998

Added lines #L996 - L998 were not covered by tests
menu.menu_event(MenuEvent::PreviousElement);
Ok(EventStatus::Handled)
})
}
ReedlineEvent::MenuUp => {
self.active_menu()
.map_or(Ok(EventStatus::Inapplicable), |menu| {
if menu.get_values().len() < 2 {
return Ok(EventStatus::Inapplicable);
}

Check warning on line 1008 in src/engine.rs

View check run for this annotation

Codecov / codecov/patch

src/engine.rs#L1006-L1008

Added lines #L1006 - L1008 were not covered by tests
menu.menu_event(MenuEvent::MoveUp);
Ok(EventStatus::Handled)
})
}
ReedlineEvent::MenuDown => {
self.active_menu()
.map_or(Ok(EventStatus::Inapplicable), |menu| {
if menu.get_values().len() < 2 {
return Ok(EventStatus::Inapplicable);
}

Check warning on line 1018 in src/engine.rs

View check run for this annotation

Codecov / codecov/patch

src/engine.rs#L1016-L1018

Added lines #L1016 - L1018 were not covered by tests
menu.menu_event(MenuEvent::MoveDown);
Ok(EventStatus::Handled)
})
}
ReedlineEvent::MenuLeft => {
self.active_menu()
.map_or(Ok(EventStatus::Inapplicable), |menu| {
if menu.get_values().len() < 2 {
return Ok(EventStatus::Inapplicable);
}

Check warning on line 1028 in src/engine.rs

View check run for this annotation

Codecov / codecov/patch

src/engine.rs#L1026-L1028

Added lines #L1026 - L1028 were not covered by tests
menu.menu_event(MenuEvent::MoveLeft);
Ok(EventStatus::Handled)
})
}
ReedlineEvent::MenuRight => {
self.active_menu()
.map_or(Ok(EventStatus::Inapplicable), |menu| {
if menu.get_values().len() < 2 {
return Ok(EventStatus::Inapplicable);
}

Check warning on line 1038 in src/engine.rs

View check run for this annotation

Codecov / codecov/patch

src/engine.rs#L1036-L1038

Added lines #L1036 - L1038 were not covered by tests
menu.menu_event(MenuEvent::MoveRight);
Ok(EventStatus::Handled)
})
Expand Down