Skip to content

Commit

Permalink
Add vim-like keybindings for monthly/yearly shifts in DateSelect
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaelmello committed Dec 27, 2023
1 parent 81f33c5 commit f2e8cb1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
- Ctrl-j/Ctrl-g for enter/cancel
- Added 'with_starting_filter_input' to both Select and MultiSelect, which allows for setting an initial value to the filter section of the prompt.
- Added 'without_filtering' to both Select and MultiSelect, useful when you want to simplify the UX if the filter does not add any value, such as when the list is already short.
- Added 'with_answered_prompt_prefix' to RenderConfig to allow customization of answered prompt prefix
- Added 'with_answered_prompt_prefix' to RenderConfig to allow customization of answered prompt prefix.
- Added vim-like keybindings for monthly/yearly shifts on DateSelect.

### Fixes

Expand Down
8 changes: 6 additions & 2 deletions inquire/src/prompts/dateselect/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,14 @@ impl InnerAction for DateSelectPromptAction {
fn from_key(key: Key, config: &DateSelectConfig) -> Option<Self> {
if config.vim_mode {
let action = match key {
Key::Char('k', KeyModifiers::NONE) => Some(Self::GoToPrevWeek),
Key::Char('j', KeyModifiers::NONE) => Some(Self::GoToNextWeek),
Key::Char('h', KeyModifiers::NONE) => Some(Self::GoToPrevDay),
Key::Char('l', KeyModifiers::NONE) => Some(Self::GoToNextDay),
Key::Char('k', KeyModifiers::NONE) => Some(Self::GoToPrevWeek),
Key::Char('j', KeyModifiers::NONE) => Some(Self::GoToNextWeek),
Key::Char('h', KeyModifiers::CONTROL) => Some(Self::GoToPrevMonth),
Key::Char('l', KeyModifiers::CONTROL) => Some(Self::GoToNextMonth),
Key::Char('k', KeyModifiers::CONTROL) => Some(Self::GoToPrevYear),
Key::Char('j', KeyModifiers::CONTROL) => Some(Self::GoToNextYear),
_ => None,
};

Expand Down

0 comments on commit f2e8cb1

Please sign in to comment.