Repository navigation
WIP: bridge drops structurally unmirrable binds silently, by class (#612) - #613
Merged
Merged
Conversation
…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.
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 条集逐名全等:
集外新红 = 0。账目闭合:master 基线 635/8 → 本 PR 638/8,+3 恰为三颗新钉,且三颗在 CI 均为 ok( 本地门见簇 REPORT(定向 issue612 3/3、engine_bind 2/2,2026-10-27 06:46 UTC 新鲜日志)。保持 draft,待主会话审合。 |
caomengxuan666
marked this pull request as ready for review
October 27, 2026 07:03
This was referenced Oct 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 --lockedrc=0(首轮,按旧口径代码)。cargo test -p niubash-runtime --lib issue6123/3 过 rc=0;engine_bind过滤 2/2 过 rc=0(2026-10-27 06:46 UTC 新鲜日志,非旧产物)。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 逐字核对(仅作动机实例与钉素材,不进判据)。