feat(macos): add editor find options and replace-in-file - #346
Merged
Conversation
1lck
reviewed
Aug 30, 2026
Uh oh!
There was an error while loading. Please reload this page.
1lck
reviewed
Aug 30, 2026
Uh oh!
There was an error while loading. Please reload this page.
1lck
reviewed
Aug 30, 2026
Uh oh!
There was an error while loading. Please reload this page.
Wz58luck
commented
Aug 30, 2026
ContributorAuthor
已fix |
- Add FindInFileOptions/FindInFileMatcher with Match Case, Whole Words, and Regular Expression matching aligned with project search semantics - Extend FindBarView with an options menu, expandable replace row (Replace / Replace All), and invalid-regex error state - Replace-next routes through insertText for standard undo; replace-all commits via shouldChangeText + textStorage as a single undo step - Register replace-in-file (Cmd+R) in the command catalog, action registry, Navigate menu, Keymap settings, and zh-Hans localization Closes1lck#327
- Unify replacement template docs and comments on $n numeric capture
groups; ${name} named-group templates are not expanded by the current
SDK and return verbatim
- Bind replace notifications to the active document: notifications now
carry documentID and CodeTextView ignores mismatched targets so split
editors never replace the wrong file
- Recompute matches across the whole document for regex queries where
matches can span lines; keep the line-window incremental path for
single-line literal queries
- Add regression tests for cross-line regex matches and notification
document gatingWz58luckforce-pushed
the
feat/editor-find-replace
branch
from
August 30, 2026 06:40
0314740 to
df0337cCompareUh oh!
There was an error while loading. Please reload this page.
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 freeto 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.
背景
Closes#327。为编辑器内查找补全匹配选项与替换能力,与项目级搜索的体验保持一致。
变更
FindInFileOptions/FindInFileMatcher(纯 Foundation 值类型):Match Case、Whole Words(标准词边界:字母/数字/下划线,串首串尾视为边界)、Regular Expression(NSRegularExpression;与 Whole Words 同开时模式外包\b(?:…)\b);零宽度匹配跳过;非法正则只呈现错误态不抛错;字面量替换原样使用,正则替换支持$n捕获组模板。FindBarView纵向扩展:选项菜单(任一开启时着色)、可展开替换行(Replace / Replace All,无匹配时禁用)、非法正则时查找图标显示错误色;替换行展开后焦点移到替换输入框。insertText(_:replacementRange:)标准输入管线(撤销、委托回调与手工编辑一致),替换后自动跳到下一处并跳过替换文本新产生的匹配;Replace All 通过shouldChangeText+NSTextStorage批量替换 +didChangeText一次提交,形成单个撤销步骤,之后整篇重算匹配。replace-in-file命令注册进LitheCommandCatalog(默认 Cmd+R)、LitheActionRegistry、canPerformShortcutCommand与 Navigate 菜单,可在 Keymap 中自定义;Cmd+F 行为保持现状,Cmd+R 在查找/替换行之间切换;Esc 关闭行为不变。AppModel的文件内查找门面抽取为AppModel+FindInFile.swift(满足 1800 行上限)。测试
FindInFileMatcherTests(13 项:大小写/音调不敏感回归、Match Case、全词边界、正则捕获组展开、非法模式、零宽度跳过、子范围枚举等);扩展EditorChromeModelTests;KeyboardShortcutTests命令数 31→32;LitheCoreLogicTests查找调用点同步新签名。./scripts/test-macos.sh:677 tests / 79 suites 全部通过。verify-test-stability.sh、test-stability-macos.sh -- --filter FindInFileMatcher、verify-service-boundaries.sh全部通过。变更后:
