You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(editor): add Core support for built-in rainbow highlighting - #201
我在本地按这个思路实现并加了测试,cargo test -p lithe-editor 全部通过,代码放在下面供参考:
参考实现(find.rs)
/// How many rejected whole-identifier candidates may make the search scan part of a candidate/// again before it stops and reports `truncated`. Only a query with punctuation inside it, such/// as `a.b`, rescans; a query of identifier characters skips each rejected run in linear time.constMAX_IDENTIFIER_RETRIES:usize = 100_000;/// Whether `source[at..through]` stands as a whole identifier: an identifier character at/// either edge of the match must not continue into the character beside it. A punctuation edge,/// as in `(foo` or `foo(`, may touch anything.fnidentifier_bounded(source:&str,at:usize,through:usize) -> bool{let matched = &source[at..through];let joins = |edge:Option<char>,beside:Option<char>| {
edge.is_some_and(identifier_continues) && beside.is_some_and(identifier_continues)};
!joins(matched.chars().next(), source[..at].chars().next_back())
&& !joins(matched.chars().next_back(), source[through..].chars().next())}/// The first offset of `text` after a rejected candidate at `at` where a whole identifier may/// start. Each offset inside the identifier run that begins at `at` follows an identifier/// character and starts with one, so no match can start there; the search resumes after the/// run, or one character on when the candidate starts with punctuation.fnnext_identifier_candidate(text:&str,at:usize) -> usize{for(offset, character)in text[at..].char_indices(){if !identifier_continues(character){return at + if offset == 0{ character.len_utf8()}else{ offset };}}
text.len()}// In command(): `record` pushes a match (and its edit) and returns Ok(false) at MAX_MATCHES.if request.whole_identifier{letmut from = 0;letmut retries = 0;whileletSome(m) = matcher.find_at(text, from){
cancellation::check()?;let(at, through) = (start + m.start(), start + m.end());ifidentifier_bounded(source, at, through){if !record(at, through,None)? {
truncated = true;break;}
from = m.end();continue;}
from = next_identifier_candidate(text, m.start());if from < m.end(){
retries += 1;if retries > MAX_IDENTIFIER_RETRIES{
truncated = true;break;}}}}else{for captures in matcher.captures_iter(text){/* unchanged, via record(..., Some(&captures)) */}}
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
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.
关联 Issue
历史背景见 Lithe-IDEA #2393。桌面端消费者:1lck/Lithe-IDEA #2420。
类型
改动
rainbowLightColors/rainbowDarkColors。无效显式色板按对应主题回退,并记录editor.preferences.palette_fallback_selected;未知偏好字段继续兼容。textDocument/documentHighlight静态/动态能力及规范化。保留可选kind(Text/Read/Write),最多 4096 个有效项,返回truncated;无结果返回空数组和 false。editor.find.wholeIdentifier支持 Unicode ID_Continue、连接控制符及$的完整标识符边界。纯标识符保持线性搜索;含标点的候选支持重叠重试及 100000 次预算,耗尽时返回 truncated。范围
共享实现供 macOS 和 Windows 共用桌面端消费。宿主设置、呈现和默认依赖 pin 由 #2420 在本 PR 合入后更新。本 PR 不替代原生桌面验收。
验证
-D warnings已尝试评审要求的四 crate 全量测试。Core 的 881 项中有范围外 Git 集成断言失败和超时,且广域产物使磁盘空间不足;终止该轮后复用已编译 EXE 完成上述受影响测试。不声明 Core 全量测试通过。 未改 Git 模块或放宽测试。产物压缩后恢复空间,任务测试进程已清理。
Linux CI 后续
功能修复提交
6eccef4的 Linux 编辑器/LSP、格式、日志、注释和 clippy 检查通过。该轮唯一失败为既有 workspace 容器列表“非零退出结果映射”测试:它通过临时可执行脚本走了不必要的启动边界,实际返回 unavailable,日志未保留启动错误,不能确认具体 OS 原因。独立提交
4f4cc06c让此契约单测直接验证answer的非零退出映射,扩展为全平台;保留 Unix 的真实 FakeEngine 启动、参数和 missing-engine 端到端覆盖。未改生产代码,未重试掩盖断言。Windows 定向测试、workspace all-targets clippy、格式、注释/Rustdoc、platform gate 和稳定性扫描通过;最新提交4f4cc06c的 11 项检查均已通过,包括 Linux、macOS、Windows、Rust Core gate、契约文档、四语 SDK 和 SDK 端到端。评审意见处理状态
已按原评审逐项核对生产实现、契约和回归用例,6 项新增问题与 1 项既有兼容问题均已处理:
桌面 #2420 已适配这些行为,继续保持 Draft;本 PR 合入后再更新其默认固定修订,不提前固定未合入分支。