Conversation
外部化 gpui-component 时 InputState 的 .multi_line(false) 换成了恒为多行的
EditorState,且 macOS 上 Enter 自带的 key_char("\n") 会被平台插入输入框
(旧单行输入在 normalize_input 里剥掉换行),回车变成换行 + 查询。
- create_simple_editor: 加 .submit_on_enter(true),编辑态不再自己插换行
- SimpleCodeEditor::render: plain Enter 时 stop_propagation,消费掉平台那次
文本插入;Shift+Enter 仍保留换行
- 新增回归测试 enter_applies_the_filter_without_inserting_a_newline
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.
问题
表数据页面的 WHERE / ORDER BY 过滤条里按回车,查询会发出,但同时插入了一个换行,输入框被撑成两行。
原因
两层叠加:
2f723298a Externalize gpui component integration把InputState+.multi_line(false)换成了恒为多行的EditorState(EditorMode::MULTI_LINE = true),新 API 里已没有multi_line(false)。key_char = "\n"(gpui_macos/src/events.rs),Window::dispatch_keystroke在 keydown 未被消费时会把key_char插入输入框。旧的单行输入在normalize_input(gpui_base .../input/base/state.rs)里剥掉\n\r,多行编辑器不剥。所以单加
.submit_on_enter(true)不够:它只让编辑态自己不插换行(insert_newline = is_multi_line() && (!submit_on_enter || shift)),随后平台那次文本插入照旧。改动
create_simple_editor:.submit_on_enter(true)。SimpleCodeEditor::render:外层div上 plain Enter 时cx.stop_propagation(),消费掉平台那次"\n"插入。keymap 动作分发早于 key_down 监听,InputEvent::PressEnter链路不变,Shift+Enter 仍换行。验证
enter_applies_the_filter_without_inserting_a_newline(真窗口 +Root):输入age > 18后 Enter,文本保持age > 18且触发一次 QueryApply;Shift+Enter 得到age > 18\n。.submit_on_enter(true)后该测试转红(left: "age > 18"/right: "age > 18\n")。cargo test -p db_view --lib→ 699 passed, 0 failed;cargo clippy -p db_view --all-targets该文件无新增告警。