1jehuang / 1jehuang/jcode

Make Ctrl+F/Ctrl+B input-cursor movement configurable

Open
#919 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

autonomous: no enhancement priority: low triage: needs-decision ux
Dominant language
Rust
Stars
19.9k
Forks
2.3k
Avg merge
2d 7h
Merged PRs (30d)
30

Description

Problem

Ctrl+F / Ctrl+B behavior is hardcoded and cannot be configured.

Today they are hardcoded to word motion, but single-character movement is the default behavior in Emacs, in every readline-based shell, and in the standard text fields of macOS apps (Cocoa's built-in Emacs-style keybindings). Users who expect Ctrl+F / Ctrl+B to move by one character cannot get that behavior through any [keybindings] setting; changing it currently requires editing Rust code.

Current behavior

In crates/jcode-tui/src/tui/app/input.rs, handle_control_key:

KeyCode::Char('b') => {
    if app.cursor_pos > 0 {
        app.cursor_pos = app.find_word_boundary_back();
    }
    true
}
KeyCode::Char('f') => {
    if app.cursor_pos < app.input.len() {
        app.cursor_pos = app.find_word_boundary_forward();
    }
    true
}

So jcode's Ctrl+F / Ctrl+B behave like Emacs M-f / M-b (word motion) rather than C-f / C-b (single character). Single-character movement currently exists only as bare Left/Right arrows in handle_basic_key. Word motion already exists as Alt+F / Alt+B in handle_alt_key.

The [keybindings] config (KeybindingsConfig in crates/jcode-config-types/src/lib.rs) covers scroll, model/effort switching, workspace nav, and pane toggles, but has no fields for input-editor motion.

Desired behavior

Make input-editor cursor movement configurable so Ctrl+F / Ctrl+B can be set to single-character movement, for example:

[keybindings]
cursor_left  = "ctrl+b"   # backward-char
cursor_right = "ctrl+f"   # forward-char
word_left    = "alt+b"    # backward-word (current behavior)
word_right   = "alt+f"    # forward-word (current behavior)
cursor_home  = "ctrl+a"
cursor_end   = "ctrl+e"

This keeps the motivating use case (Emacs/readline/macOS-style Ctrl+F/Ctrl+B as single-character movement) while leaving the shipped default as a separate decision.

Proposal

  1. Add input-motion fields to KeybindingsConfig (and the default registry in crates/jcode-config-types/src/keybindings.rs).
  2. Route handle_control_key / handle_alt_key's b/f (and a/e) behavior through those configured chords instead of hardcoding them.
  3. Honor the existing config hot-reload path (refresh_keybindings_if_config_reloaded).
  4. Document the new keys in the default config template and keybinding docs.

Notes / decisions needed

  • Whether to change the shipped default for Ctrl+F / Ctrl+B to single-character movement, or keep the current word-motion default and only make it configurable.
  • Whether to also expose kill/delete and history navigation as configurable keys, or keep this issue scoped to cursor movement only.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with handle_control_key and handle_alt_key in crates/jcode-tui/src/tui/app/input.rs, then inspect KeybindingsConfig and the default registry in crates/jcode-config-types/src/lib.rs and keybindings.rs. Review the default config template, keybinding documentation, and refresh_keybindings_if_config_reloaded. Done means cursor-motion chords are configurable, hot reload is honored, and the chosen default behavior is documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.