feat(view): mark prose-inferred params in Structure
Show inferred function parameters with a dashed chip and outline annotation so view surfaces v0.3 param elevation without changing the redundant call surfaces. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
551f4ff322
commit
4f09e515ee
4 files changed
+74
-3
No files matched your search
@@ -355,6 +355,16 @@ section.block > h2 {
|
||||
border: 1px solid transparent;
|
||||
color: var(--ink);
|
||||
}
|
||||
.chip.inferred {
|
||||
border-style: dashed;
|
||||
border-color: var(--line);
|
||||
opacity: 0.92;
|
||||
}
|
||||
.chip.inferred::after {
|
||||
content: " ↑";
|
||||
font-size: 0.65em;
|
||||
opacity: 0.7;
|
||||
}
|
||||
.nested {
|
||||
margin: 0.45rem 0 0.15rem 0.15rem;
|
||||
padding-left: 0.85rem;
|
||||
@@ -684,6 +694,15 @@ section.block > h2 {
|
||||
font-size: 0.66rem;
|
||||
margin-left: 0.2rem;
|
||||
}
|
||||
.outline-item .ol-params {
|
||||
margin-left: 0.25rem;
|
||||
font-family: var(--mono);
|
||||
font-size: 0.62rem;
|
||||
color: var(--muted);
|
||||
}
|
||||
.outline-item .ol-param.inferred {
|
||||
border-bottom: 1px dashed var(--line);
|
||||
}
|
||||
.fun-card:target {
|
||||
outline: 2px solid var(--focus);
|
||||
outline-offset: 2px;
|
||||
|
||||
+53
-1
@@ -812,6 +812,26 @@ fn outline_fun(fun: &Function, parent_path: &str) -> String {
|
||||
escape(&fun.name),
|
||||
fun.level,
|
||||
);
|
||||
if !fun.params.is_empty() {
|
||||
s.push_str(" <span class=\"ol-params\">");
|
||||
for (i, p) in fun.params.iter().enumerate() {
|
||||
if i > 0 {
|
||||
s.push(' ');
|
||||
}
|
||||
if p.inferred {
|
||||
s.push_str(&format!(
|
||||
"<span class=\"ol-param inferred\" title=\"inferred\">{}</span>",
|
||||
escape(&p.name)
|
||||
));
|
||||
} else {
|
||||
s.push_str(&format!(
|
||||
"<span class=\"ol-param\" title=\"explicit\">{}</span>",
|
||||
escape(&p.name)
|
||||
));
|
||||
}
|
||||
}
|
||||
s.push_str("</span>");
|
||||
}
|
||||
if !fun.children.is_empty() {
|
||||
s.push_str("<ul>");
|
||||
for child in &fun.children {
|
||||
@@ -920,7 +940,17 @@ fn render_fun(
|
||||
if !fun.params.is_empty() {
|
||||
s.push_str("<div class=\"params\">");
|
||||
for p in &fun.params {
|
||||
s.push_str(&format!("<span class=\"chip\">{}</span>", escape(&p.name)));
|
||||
let (cls, title) = if p.inferred {
|
||||
("chip inferred", "inferred from prose / body")
|
||||
} else {
|
||||
("chip", "explicit + param")
|
||||
};
|
||||
s.push_str(&format!(
|
||||
"<span class=\"{cls}\" title=\"{title}\">{name}</span>",
|
||||
cls = cls,
|
||||
title = title,
|
||||
name = escape(&p.name),
|
||||
));
|
||||
}
|
||||
s.push_str("</div>");
|
||||
}
|
||||
@@ -1625,6 +1655,28 @@ mod tests {
|
||||
assert!(html.contains(">xs<") || html.contains("vars-name\">xs"), "{html}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn structure_marks_inferred_params() {
|
||||
let src = include_str!("../../tests/markup-v03/inc-prose.mq.md");
|
||||
let module = crate::parse::parse_source(src).unwrap();
|
||||
let add = module
|
||||
.functions
|
||||
.iter()
|
||||
.find(|f| f.name == "加一函数")
|
||||
.expect("加一函数");
|
||||
assert!(add.params.iter().any(|p| p.name == "n" && p.inferred));
|
||||
let html = render_module_structure(&module, src);
|
||||
assert!(
|
||||
html.contains("chip inferred") && html.contains(">n<"),
|
||||
"expected inferred chip for n: {html}"
|
||||
);
|
||||
let outline = render_function_outline(&module);
|
||||
assert!(
|
||||
outline.contains("ol-param inferred") && outline.contains(">n<"),
|
||||
"expected outline inferred param: {outline}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stream_panel_gated_on_llm_or_agent_import() {
|
||||
let hello = crate::parse::parse_source(include_str!("../../tests/structure/hello.mq.md"))
|
||||
|
||||
Reference in new issue
Block a user