Repository navigation
fix(nsh): leave Copy to the page when the focused editor selects nothing - #6726
Conversation
The rich editor bound Mod+C and Mod+X whatever its selection, and the composer's hidden caret sink holds the keyboard focus while a session is open. So the key never reached the Edit menu: the editor copied nothing, and the selection in the session's output — which belongs to the surface, not to the editor — was never copied. Bind the two keys only while something is selected, as Escape is bound only while there is something to collapse, so the key goes on to the menu. The focused text view's `copy:` then falls back to the surface's selected output when it has nothing selected itself, and its menu validation offers the item then too; a view of the surface's own that has the keyboard focus resolves the surface it belongs to instead of a dead end. The plain editor keeps its line-wise copy: with no selection it copies the line. Verified: `nsh-base`'s base suite (785 tests) and a new rich-editor case that fails without the editor change; `cargo clippy` clean on the touched crates. Generated-by: Maka
a735f4b to
0f07c1e
Compare
|
Post-merge review of the six-file change at The original failure is supported by the implementation: I ran the original affected Rust suite locally: 203 passed, one ignored. Two additional tests through the actual headless engine pass: cutting selected text updates both clipboard and document before releasing the empty caret's Copy/Cut bindings; copying These tests establish the shared editor/keymap behavior, not the complete native responder path. I did not run real macOS Copy/Cut menus, secure-field interaction, secondary-window selection, or Windows/Linux desktop clipboard interaction. In particular, the macOS fallback and menu enablement still require native acceptance; the author's macOS checks remain attributed to the author. No database schema or wire contract changes are involved. CI follow-up: both workflow aggregates have now completed with failure (attempt 1). I read their original logs and checked their explicit checkout commits. The PR run 42654338825 used merge commit The landed run 42655921790 checks out For comparison, I read the corresponding original logs from the preceding
|
…hEditor keys static (#6731) Keep RichEditor's Mod+C and Mod+X bindings static across selection transitions so back-to-back Select All -> Copy bursts and ComposerInput's editor-internal Ctrl+C fallback run deterministically without key-table churn, while routing Copy and Escape to an active surface output selection at the platform boundary on macOS, Windows, and TUI when the focused editor has no native selection of its own. Refs #6726 Generated-by: Antigravity
English
Summary
With a
RichEditorholding keyboard focus and nothing selected, Cmd+C and Cmd+X were consumed by the editor even when the page had selected output (for example, a session's output). Copy did nothing, so the page's selection never reached the clipboard.A focused text field had the same dead end on macOS: when the field itself had no selection, the Edit menu's Copy was disabled and never copied the page's selection.
The rich editor now registers Mod+C and Mod+X only while it has a selection; with nothing selected, the keys go on to the page's keymap and the platform. The macOS text views fall back to the surface's selection when they have none, and the Edit menu offers Copy then. With a selection, the editor copies its own content as before. The plain
Editorkeeps its line-wise copy with no selection, and no new configuration or API is added.Verification
cargo test -p nsh-base --test base rich_editor::— 203 passed, 1 ignored.copy_with_nothing_selected_is_left_to_the_page; with the key-table change reverted,claims_key("mod+c")is true and the test fails (checked by ablation).cargo test -p nsh-platform-macos --lib— 102 passed.cargo check -p nsh-platform-macosandcargo clippy -p nsh-base -p nsh-platform-macos -p nsh-testing --all-targets— no new warnings (the existinglarge_enum_variantandcollapsible_ifwarnings remain).rustfmt --checkpasses on the touched files.nsh test … --target macos) and the Windows/Linux builds. The macOScopy:fallback, its menu validation, and the child-view surface resolution have no automated test here.AI use
Select exactly one:
Tool(s) and scope: Maka implemented the change and its test (commit trailer
Generated-by: Maka). Codex reviewed it, ran the ablation, and collapsed duplicated key predicates and menu-validation conditions without changing behavior.Checklist
Does this PR entail a change in behavior?
中文
摘要
RichEditor持有键盘焦点且没有选区时,即使页面上有选中内容(例如会话输出),Cmd+C 与 Cmd+X 也会被编辑器消费。Copy 什么都不做,页面的选区因此永远进不了剪贴板。macOS 上聚焦的文本框也有同样的死路:文本框自身没有选区时,Edit 菜单的 Copy 被置灰,不会复制页面的选区。
现在富文本编辑器只在有选区时注册 Mod+C 和 Mod+X;没有选区时,按键继续交给页面的 keymap 和平台处理。macOS 文本视图在自身没有选区时回退到 surface 的选区,Edit 菜单也随之提供 Copy。有选区时,编辑器仍像以前一样复制自身内容。普通
Editor保持无选区时按行复制的行为,没有新增配置或 API。验证
cargo test -p nsh-base --test base rich_editor::—— 203 个通过,1 个忽略。copy_with_nothing_selected_is_left_to_the_page;把键表改动回退后,claims_key("mod+c")为 true,用例失败(已用消融确认)。cargo test -p nsh-platform-macos --lib—— 102 个通过。cargo check -p nsh-platform-macos与cargo clippy -p nsh-base -p nsh-platform-macos -p nsh-testing --all-targets—— 无新增 warning(既有的large_enum_variant、collapsible_if仍在)。rustfmt --check在被改文件上通过。nsh test … --target macos)以及 Windows/Linux 构建。macOS 的copy:回退、菜单校验和子视图的 surface 解析在这里没有自动化测试。AI 参与
只选一项:
工具与范围:Maka 实现了改动及其测试(提交 trailer 为
Generated-by: Maka)。Codex 做了评审、消融,并在不改变行为的前提下合并了重复的按键判定和菜单校验条件。检查项
这个 PR 是否带来行为变化?