Skip to content

WIP: bridge drops structurally unmirrable binds silently, by class (#612) - #613

Merged
caomengxuan666 merged 1 commit into
masterfrom
fix/612-fzf-bind-silence
Oct 27, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
fix/612-fzf-bind-silence

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

WIP: 按主会话审合,先勿合。

Fixes #612

裁定与修订(必读)

原裁定 (b) 是按 fzf --bash 脚本钉精确三元组白名单。用户纠正后已修订为机制分类(用户原话:「可能不止 fzf 消费这个,不要打地鼠」;修订裁定见 #612 后续评论):同类 bind 的来源不止一个工具,逐个案加例外永远追不完。本 PR 因此没有任何按工具名/脚本来源的匹配(无 fzf 专属表、无来源判据),判据只有序列形状与函数类别本身;fzf 仅是动机实例与回归钉素材。

实现(crates/niubash-runtime/src/repl.rs)

桥(add_engine_bind_keybindings)把不可用 bind 按机制分两类,记录进既有 unusable 列表时带原因分类 UnusableBind { keyseq, reason }:

① 结构性不可表达类 —— 静默丢弃(仍记入列表供诊断,warn_unusable_engine_bindings 只过滤打印)

  • ChainedSequence:多键/链式序列。reedline 的绑定是单个 (modifiers, key),链式序列无对应表达。判据是词法扫描(is_chained_key_sequence:序列须干净地切成 ≥2 个键单元;残缺/不可解析的序列扫描会停滞、不算链——归 ② 警告,防把误写当结构性吞掉)。
  • ModeToggleFunction:readline 编辑模式切换函数(vi-editing-mode / emacs-editing-mode —— Bash 手册可绑函数表里恰好这两个的封闭类)。切换 keymap 在 niu 是会话级 EditorMode 选择、不是逐键 widget,桥永远无法镜像,与 keymap、序列、来源都无关。

② 其余不可用 —— 维持逐条启动警告(可行动的新信息)

  • 不可解析序列(如悬空的 \C-)、未知函数名(如笔误)、以及真实但 niu 未镜像的非切换类函数(如单键上的 redraw-current-line)。

红线遵守:不碰 Ctrl+Z 语义(没有把模式切换映射成真行为,(c) 仍否);其余 unusable 警告行为不变;可镜像 bind(含 fzf 的 \C-t/\C-r/Alt-C 三条 bind -x)的镜像逻辑零改动。

文档 (d)

docs/src/completion.md 新增「Key bindings from other tools」一节:写的是限制类(多键序列与模式切换不镜像、任何工具同理),fzf 只作例子;其余不可用仍警告、fzf 集成全功能照旧写明。

回归钉(名字带 612,均在 repl.rs lib 测试内)

  • issue612_fzf_workaround_binds_drop_silently:fzf 0.74.5 原文四条(类实例)——三 target 下记录为结构性原因、警告集为空;同脚本三条 bind -x 仍按注册序镜像为 __niu_bindx 0/1/2。
  • issue612_structural_silence_is_source_agnostic:虚构第三方形状自证与来源无关——自造链式 Execute/Macro、自造键位/方向的模式切换同样静默;未知函数、悬空修饰符序列、单键 redraw-current-line 仍警告。
  • issue612_chained_sequence_scan:链式扫描的词法边界(残缺序列不算链)。
  • 既有钉 engine_bind_entries_mirror_into_reedline_keybindings 同步更新期望:\C-g(未知函数)仍警告类、\C-x\C-f 改记 ChainedSequence(仍在列表内)。

本地门(构建槽、JOBS=1、净化环境,日志 + .done 在簇目录)

  • cargo fmt --check -p niubash-runtime 全清、改动文件 CR=0;cargo build --locked rc=0(首轮,按旧口径代码)。
  • 按新口径重跑定向:cargo test -p niubash-runtime --lib issue612 3/3 过 rc=0;engine_bind 过滤 2/2 过 rc=0(2026-10-27 06:46 UTC 新鲜日志,非旧产物)。
  • lib 覆盖路径声明:cargo test --workspace 不执行 niubash-runtime 的 lib 二进制,故 lib 面以定向跑(本机)+ GitHub CI 全集对账为准——CI 的 lib 失败集须与已裁定 runner 环境 8 条(7× plugins::sources/sync 的 git-not-found + 1× shell cd 短名形)逐名全等,结论补在证据评论与簇 REPORT。

fzf 出处:官方 release 0.74.5(c0a193e0)fzf --bash 输出与仓库 shell/key-bindings.bash:144-149 逐字核对(仅作动机实例与钉素材,不进判据)。

…bash#612)

The engine->reedline bridge warned at every startup about bind
entries it cannot mirror. Two classes of those are structural --
the editor cannot express them by design -- so the warning is
unactionable noise whoever emitted them (motivating instance:
fzf --bash registers a chained-sequence bind and \C-z editing-mode
toggles; per the #612 ruling revision the criterion is the
mechanism, never the emitter):

- chained/multi-key sequences (reedline binds single keys), and
- readline editing-mode toggle functions (vi-editing-mode /
  emacs-editing-mode -- keymap switching is a session-level
  EditorMode choice, not a per-key widget).

Unusable entries are still recorded, now classified by reason in
UnusableBind; warn_unusable_engine_bindings prints only the
actionable remainder (unparseable sequences, unknown functions,
real-but-unmirrored non-toggle functions). No behavior changes
for mirrored binds; Ctrl+Z semantics untouched.

Docs: completion.md gains a limitation-class section (fzf as the
example). Regression pins: fzf shapes as class instances, invented
third-party shapes proving source-agnostic silence, warning
controls, and the lexical chain scan.
@caomengxuan666

Copy link
Copy Markdown
Member Author

集成证据(CI 对账完成)

CI run 40463744290:其余 job 全 success(cross-check ubuntu/macos、cross-target ×5、musl smoke;nightly skipped),唯一 failure = build-and-test 的 cargo test 步(fmt/clippy/build 均已过、测试步才红)。

lib 对账(逐名):niubash-runtime lib 638 passed / 8 failed。8 条失败与已裁定的 runner 环境 8 条集逐名全等:

  • plugins::sources::tests::drifted_trusted_tree_is_degraded_and_restore_repairs_it
  • plugins::sources::tests::restore_source_rebuilds_the_pinned_commit
  • plugins::sources::tests::run_git_bounded_kills_a_hung_child_at_the_deadline
  • plugins::sources::tests::sign_source_upgrades_policy_and_update_re_gates
  • plugins::sources::tests::update_records_previous_and_rollback_restores_git_origin
  • plugins::sources::tests::verb_fetch_budget_bounds_an_explicit_fetch_by_default
  • plugins::sync::tests::sync_isolates_a_stalled_source_and_still_installs_the_rest
  • shell::tests::execute_line_syncs_cd_before_following_windows_child_command

集外新红 = 0。账目闭合:master 基线 635/8 → 本 PR 638/8,+3 恰为三颗新钉,且三颗在 CI 均为 ok(issue612_fzf_workaround_binds_drop_silently / issue612_structural_silence_is_source_agnostic / issue612_chained_sequence_scan);既有钉 engine_bind_entries_mirror_into_reedline_keybindings 在 CI 通过。

本地门见簇 REPORT(定向 issue612 3/3、engine_bind 2/2,2026-10-27 06:46 UTC 新鲜日志)。保持 draft,待主会话审合。

@caomengxuan666
caomengxuan666 marked this pull request as ready for review October 27, 2026 07:03
@caomengxuan666
caomengxuan666 merged commit e3315c6 into master Oct 27, 2026
11 of 12 checks passed
@caomengxuan666
caomengxuan666 deleted the fix/612-fzf-bind-silence branch October 30, 2026 01:42
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.

[interactive][compat] fzf --bash integration warns on every startup: two workaround binds cannot be mirrored

1 participant