Skip to content

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

Merged
jdx merged 2 commits into
jdx:mainfrom
danielyrovas:daniel/feat/use-ctrl-n-ctrl-p-for-vertical-movement-in-lists
Sep 29, 2026
Merged

jdx merged 2 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
Contributor

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 shortcuts to move down and up in list, selection, and multi-selection menus, both during filtering and outside filter mode.
  • Bug Fixes
    • In list and selection filters, control-character input is no longer handled as printable text.

@coderabbitai

coderabbitai Bot commented Jul 27, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Advanced

Run ID: 8015592f-f591-4aca-92f0-56bf33c2174a

📥 Commits

Reviewing files that changed from the base of the PR and between f9a2460 and 37c413d.

📒 Files selected for processing (3)
  • src/list.rs
  • src/multiselect.rs
  • src/select.rs

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The list, multiselect, and select interfaces now accept Ctrl-N and Ctrl-P for vertical navigation. Filtering does not pass control characters to filter input.

Changes

Keyboard navigation

Layer / File(s) Summary
Centralize control-key definitions
src/input.rs
Defines crate-visible constants for the Ctrl-N and Ctrl-P control codes.
Add Ctrl-N/Ctrl-P navigation
src/list.rs, src/multiselect.rs, src/select.rs
Adds Ctrl-N and Ctrl-P as vertical navigation keys. Filtering ignores control characters as filter input.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Feature

Suggested reviewers: jdx

Merge Risk: 🟡 Moderate · up to 37c41

Existing custom toggle bindings can stop working, and users cannot discover the new shortcuts; preserve the bindings and update the help text before merging.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 37c41

Ctrl-N and Ctrl-P add navigation without an identified security bypass. A caller that configured either key to toggle selections will instead get navigation, which can change the selections returned on confirmation.

Retained concerns

  • Low · architecture · observed: MultiSelect now gives Ctrl-N and Ctrl-P navigation precedence over the public toggle_key setting. Callers using either value as their toggle key can no longer toggle with that key, potentially changing the selected items returned on confirmation.
Security review details

Security Blast Radius

  • inferred — The demonstrated effect is on widget cursor movement and, for a conflicting custom toggle key, the option set returned to the caller. The inspected path does not show a new privileged sink.

Trust Boundaries and Controls

  • observed — MultiSelect obtains key events from EventReader; filtering sends only non-control characters to the generic filter handler, while confirmation checks selection bounds before returning items.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 6 files.
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding Ctrl-N and Ctrl-P for vertical movement in lists.

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

RetriggerConfidence Score: 5/5

[Low risk] Adds keyboard shortcuts for list navigation.

The PR appears safe to merge.

Summary

Adds Ctrl-N/Ctrl-P vertical navigation across interactive list controls.

  • Defines shared Ctrl-N and Ctrl-P input constants.
  • Supports the shortcuts in list, selection, and multi-selection menus, including during filtering.
  • Prevents control characters from being inserted into filter text.

Reviews (5) · Last reviewed commit: "fix: honour Ctrl-N/Ctrl-P while filterin..."

@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.

@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.

@toyboot4e

Copy link
Copy Markdown

+1 for this PR, it would work for mise use, mise run and mise search -i.

This PR would also fix all those Ctrl-related bindings (currently they're inserted as raw bytes in filters):

demand/src/input.rs

Lines 429 to 436 in 9f192f4

Key::Char(CTRL_U) => self.handle_ctrl_u()?,
Key::Char(CTRL_W) => self.handle_ctrl_w()?,
Key::Char(CTRL_K) => self.kill_to_end()?,
Key::Char(CTRL_Y) => self.yank()?,
Key::Char(CTRL_T) => self.transpose_chars()?,
Key::Char(CTRL_D) | Key::Del => self.delete_char()?,
Key::Char(CTRL_B) => self.handle_arrow_left()?,
Key::Char(CTRL_F) => self.handle_arrow_right()?,

@danielyrovas Could you rebase it for the latest code?

@jdx
jdx marked this pull request as draft September 27, 2026 12:44
@danielyrovas
danielyrovas force-pushed the daniel/feat/use-ctrl-n-ctrl-p-for-vertical-movement-in-lists branch from f71c267 to 4d4807a Compare September 27, 2026 14:39
@danielyrovas
danielyrovas marked this pull request as ready for review September 27, 2026 14:41
@toyboot4e

Copy link
Copy Markdown

@danielyrovas Sorry from aside, the PR needs fixes, like

  • src/keys.rs: should be in src/input.rs
  • .nvim.lua: it should not be comitted

@danielyrovas
danielyrovas force-pushed the daniel/feat/use-ctrl-n-ctrl-p-for-vertical-movement-in-lists branch from 4d4807a to f9a2460 Compare September 29, 2026 00:48
greptile-apps[bot]
greptile-apps Bot previously approved these changes Sep 29, 2026
@danielyrovas
danielyrovas force-pushed the daniel/feat/use-ctrl-n-ctrl-p-for-vertical-movement-in-lists branch from f9a2460 to 37c413d Compare September 29, 2026 01:04
@greptile-apps
greptile-apps Bot dismissed their stale review September 29, 2026 01:04

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

@jdx
jdx merged commit 201068c into jdx:main Sep 29, 2026
9 checks passed
@jdx jdx mentioned this pull request Sep 28, 2026
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.

3 participants