Skip to content

feat: use Ctrl-N/Ctrl-P for vertical movement in lists - #197

Open
danielyrovas wants to merge 3 commits into
jdx:mainfrom
danielyrovas:daniel/feat/use-ctrl-n-ctrl-p-for-vertical-movement-in-lists
Open

feat: use Ctrl-N/Ctrl-P for vertical movement in lists#197
danielyrovas wants to merge 3 commits into
jdx:mainfrom
danielyrovas:daniel/feat/use-ctrl-n-ctrl-p-for-vertical-movement-in-lists

Conversation

@danielyrovas

@danielyrovas danielyrovas commented Jul 27, 2026

Copy link
Copy Markdown

A small change that allows CTRL N/CTRL P to move vertically in lists.

I especially want this feature in mise run as I use these keybinds to move in most lists

Summary by CodeRabbit

  • New Features
    • Added Ctrl-N and Ctrl-P keyboard shortcuts for moving up and down in lists, multi-select menus, and selection prompts.
    • Added Ctrl-U and Ctrl-W control-key support for input editing.
  • Bug Fixes
    • Control characters entered while filtering are no longer treated as filter text.

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Centralizes control-key constants in a new internal module and adds Ctrl-N/Ctrl-P navigation bindings to list, multiselect, and select interactions while preserving existing arrow and j/k controls.

Changes

Keyboard navigation

Layer / File(s) Summary
Centralize control-key definitions
src/keys.rs, src/lib.rs, src/input.rs
Defines shared Ctrl-N, Ctrl-P, Ctrl-U, and Ctrl-W constants, registers the internal module, and imports the editing keys into input handling.
Wire Ctrl-N/Ctrl-P navigation
src/list.rs, src/multiselect.rs, src/select.rs
Recognizes Ctrl-N for downward movement and Ctrl-P for upward movement in filtering and non-filtering keyboard handling paths.
Estimated code review effort: 2 (Simple) ~10 minutes

Suggested reviewers: jdx

Poem

A bunny taps keys in the moonlit glow,
Ctrl-N hops down, Ctrl-P hops up below.
Shared little codes now neatly align,
While arrows and j/k still shine.
“A tidy keyboard burrow!” says the bunny divine.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding Ctrl-N/Ctrl-P vertical navigation in lists.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Jul 27, 2026

Copy link
Copy Markdown

Greptile Summary

Adds shared control-key constants and enables Ctrl-N/Ctrl-P vertical navigation in list, select, and multiselect widgets, including while filtering.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
src/keys.rs Introduces shared constants for Ctrl-N, Ctrl-P, Ctrl-U, and Ctrl-W.
src/input.rs Reuses the shared Ctrl-U and Ctrl-W constants without changing input behavior.
src/lib.rs Registers the new internal keys module.
src/list.rs Adds Ctrl-N/Ctrl-P navigation in normal and filtering modes and prevents other control characters from entering filters.
src/multiselect.rs Adds Ctrl-N/Ctrl-P navigation in normal and filtering modes and prevents unhandled control characters from entering filters.
src/select.rs Adds Ctrl-N/Ctrl-P navigation in normal and filtering modes and prevents other control characters from entering filters.

Reviews (2): Last reviewed commit: "fix: honour Ctrl-N/Ctrl-P while filterin..." | Re-trigger Greptile

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/list.rs`:
- Around line 165-166: The navigation help text must document the newly
supported Ctrl-N/Ctrl-P bindings alongside the existing arrow and j/k keys.
Update the corresponding help entries near the handlers in src/list.rs (around
lines 330), src/multiselect.rs (around line 610), and src/select.rs (around line
453); no handler changes are needed at the cited sites.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 81a736d7-4434-4831-93c6-1eb8876674ec

📥 Commits

Reviewing files that changed from the base of the PR and between 62f46d5 and 3520ed0.

📒 Files selected for processing (6)
  • src/input.rs
  • src/keys.rs
  • src/lib.rs
  • src/list.rs
  • src/multiselect.rs
  • src/select.rs

Comment thread src/list.rs
Comment on lines +165 to +166
Key::ArrowDown | Key::Char('j') | Key::Char(CTRL_N) => self.handle_down()?,
Key::ArrowUp | Key::Char('k') | Key::Char(CTRL_P) => self.handle_up(),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Keep user-facing navigation help synchronized with the new bindings.

Each handler now supports Ctrl-N/Ctrl-P, but its corresponding help text still lists only arrows and j/k.

  • src/list.rs#L165-L166: update the help text near Line 330.
  • src/multiselect.rs#L222-L223: update the help text near Line 610.
  • src/select.rs#L192-L193: update the help text near Line 453.
📍 Affects 3 files
  • src/list.rs#L165-L166 (this comment)
  • src/multiselect.rs#L222-L223
  • src/select.rs#L192-L193
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/list.rs` around lines 165 - 166, The navigation help text must document
the newly supported Ctrl-N/Ctrl-P bindings alongside the existing arrow and j/k
keys. Update the corresponding help entries near the handlers in src/list.rs
(around lines 330), src/multiselect.rs (around line 610), and src/select.rs
(around line 453); no handler changes are needed at the cited sites.

silently consume other CTRL characters with char.is_control()

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/multiselect.rs`:
- Around line 203-204: Update the help labels in print_help_keys for both
filtering and non-filtering modes to include Ctrl-N and Ctrl-P alongside the
existing navigation keys, matching the bindings in handle_down and handle_up.
- Around line 203-204: Update the key dispatch around the ArrowDown/ArrowUp arms
and the toggle_key guard so a custom toggle_key set to Ctrl-N or Ctrl-P is
handled as the toggle action rather than navigation. Preserve navigation
behavior for those keys when they are not configured as the toggle key, or
explicitly reject them as reserved if that is the established design.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: e61e360d-7f5f-4015-a84c-9af748eee70b

📥 Commits

Reviewing files that changed from the base of the PR and between 3520ed0 and f71c267.

📒 Files selected for processing (3)
  • src/list.rs
  • src/multiselect.rs
  • src/select.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/list.rs
  • src/select.rs

Comment thread src/multiselect.rs
Comment on lines +203 to +204
Key::ArrowDown | Key::Char(CTRL_N) => self.handle_down()?,
Key::ArrowUp | Key::Char(CTRL_P) => self.handle_up()?,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Advertise the new navigation keys in the help text.

print_help_keys still displays only ↑/↓ (filtering) and ↑/↓/k/j (non-filtering), so users cannot discover Ctrl-N/Ctrl-P. Update the help labels alongside these bindings.

Also applies to: 222-223

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/multiselect.rs` around lines 203 - 204, Update the help labels in
print_help_keys for both filtering and non-filtering modes to include Ctrl-N and
Ctrl-P alongside the existing navigation keys, matching the bindings in
handle_down and handle_up.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Preserve custom Ctrl-N/Ctrl-P toggle bindings.

These navigation arms now match before key if key == self.toggle_key. Because toggle_key accepts any Key, configuring it as Ctrl-N or Ctrl-P silently changes its behavior from toggling to navigation. Preserve the custom binding or explicitly reject/document these keys as reserved.

Also applies to: 222-223

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/multiselect.rs` around lines 203 - 204, Update the key dispatch around
the ArrowDown/ArrowUp arms and the toggle_key guard so a custom toggle_key set
to Ctrl-N or Ctrl-P is handled as the toggle action rather than navigation.
Preserve navigation behavior for those keys when they are not configured as the
toggle key, or explicitly reject them as reserved if that is the established
design.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant