mirror of
https://github.com/feigeCode/navop.git
synced 2026-09-22 16:01:30 +00:00
- 统一网格:card_grid_metrics 由内容区宽度计算列数/列宽,单项组与 末行不拉宽;最近区容量跟随网格列数 - 主页卡片/列表/树形三视图,视图切换改为带勾选态的下拉菜单 - 树形视图嵌入主页:侧栏实现 Render 并按 home_embedded 输出,修复 HomePage render 租约内 read(HomePage) 重入 panic;嵌入时隐藏树头部 - 团队标签中性化(muted 底),移入名称行与名称对齐;卡片/列表选中态 统一为 list_active 语义色,去掉常驻阴影与逐项「最近」角标 - 最近区改用历史语义图标;提示仅在分组筛选生效时显示;计数精简为数字 - 展开/折叠全部归入「分组」菜单;新建连接降为 outline - 侧栏收窄至 184px,折叠控制移入底部与设置同行;账户行去常驻邮箱 - 常驻连接侧栏仅非主页显示;合并 dev 并完成 universal-plugins 迁移 - 清理死代码:user_avatar 模块、Inline 变体、旧同步按钮状态机、 冲突对话框等;full test 539 通过、clippy 无告警
83 lines
3.6 KiB
Rust
83 lines
3.6 KiB
Rust
//! 语法高亮契约测试。
|
|
//!
|
|
//! 外部 gpui-component 已移除 highlighter 的 wasm 扩展 API
|
|
//! (`InstalledExtension`/`LanguageKind`/`register_wasm_manifest` 等),
|
|
//! 语言扩展加载统一由本仓库 `extension-runtime` 提供:它把 parser.wasm
|
|
//! 经 tree-sitter WasmStore 编译成原生 `tree_sitter::Language` 后注册进
|
|
//! `LanguageRegistry`。本测试按新链路验证 fenced Rust 代码块的着色。
|
|
|
|
use extension_runtime::language_extensions::InstalledExtension;
|
|
use gpui_component::highlighter::{HighlightTheme, LanguageRegistry, SyntaxHighlighter};
|
|
use ropey::Rope;
|
|
use std::path::PathBuf;
|
|
|
|
#[test]
|
|
fn markdown_editor_does_not_bundle_a_native_rust_grammar() {
|
|
// 源码契约:markdown-editor 自身不得启用任何原生 tree-sitter 语法 feature,
|
|
// fenced 语言一律由 extension-runtime 的 wasm 扩展提供。运行时注册表断言
|
|
// 不可靠——`cargo test --all` 的 feature unification 会把 main 经
|
|
// gpui-component-shell 启用的 tree-sitter-rust 一并链接进测试二进制。
|
|
let manifest = std::fs::read_to_string(concat!(env!("CARGO_MANIFEST_DIR"), "/Cargo.toml"))
|
|
.expect("Cargo.toml must be readable");
|
|
for line in manifest.lines() {
|
|
let line = line.trim();
|
|
assert!(
|
|
!line.contains("tree-sitter-rust") && !line.contains("tree-sitter-languages"),
|
|
"markdown-editor must not enable native rust grammars: {line}"
|
|
);
|
|
}
|
|
// wasm 扩展未注册时,fenced 语言必须安全回退为纯文本。
|
|
if LanguageRegistry::singleton().language("rust").is_none() {
|
|
assert_eq!(
|
|
"text",
|
|
SyntaxHighlighter::new("rust").language().as_ref(),
|
|
"an unavailable fenced language must safely fall back to text"
|
|
);
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
#[ignore = "需要 ONETCLI_TEST_LANGUAGE_EXT 指向真实 Rust 语言扩展目录"]
|
|
fn fenced_rust_code_loads_parser_and_queries_from_wasm_extension() {
|
|
let extension_dir = PathBuf::from(
|
|
std::env::var("ONETCLI_TEST_LANGUAGE_EXT")
|
|
.expect("ONETCLI_TEST_LANGUAGE_EXT must point to a Rust language extension"),
|
|
);
|
|
let extension = InstalledExtension::load_from_dir(&extension_dir)
|
|
.expect("real language extension must contain manifest, parser.wasm, and valid queries");
|
|
assert_eq!("rust", extension.manifest.name);
|
|
|
|
// 注册:wasm 语法经 tree-sitter WasmStore 编译,连同文件扩展名别名一起写入注册表
|
|
let registry = LanguageRegistry::singleton();
|
|
extension
|
|
.register(registry)
|
|
.expect("registering the rust wasm grammar must compile parser.wasm");
|
|
assert!(
|
|
registry.language("rs").is_some(),
|
|
"the manifest file extension must canonicalize the fenced alias"
|
|
);
|
|
|
|
let rust = registry
|
|
.language("rust")
|
|
.expect("registered Rust wasm grammar must resolve");
|
|
assert!(
|
|
!rust.highlights.is_empty(),
|
|
"the wasm extension must supply highlights.scm"
|
|
);
|
|
|
|
let source = "fn main() {\n let answer = 42;\n}\n";
|
|
let text = Rope::from_str(source);
|
|
let mut highlighter = SyntaxHighlighter::new("rust");
|
|
assert_eq!("rust", highlighter.language().as_ref());
|
|
assert!(highlighter.update(None, &text, None));
|
|
|
|
let theme = HighlightTheme::default_dark();
|
|
let styles = highlighter.styles(&(0..source.len()), &*theme);
|
|
assert!(
|
|
styles.iter().any(|(_, style)| style.color.is_some()),
|
|
"the wasm grammar and highlights.scm must produce colored Rust spans"
|
|
);
|
|
// 注意:新 LanguageRegistry 没有 unregister,该 #[ignore] 测试会向进程级
|
|
// 单例注册 rust 语法,与其他测试隔离运行即可。
|
|
}
|