release: v2.2.1 fix view outline rail under document

Occlusion left .doc-block open and mid-width CSS stacked the Functions/Variables rail below Structure; close the block and stack by panel container width instead.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
cflmyandCursor committed 2026-10-30 11:41:49 +08:00
1 parent 1730f26fc7
commit 58791fc7d9
10 files changed
+125 -12

No files matched your search

+57
View File
@@ -916,6 +916,17 @@ fn render_line_block(
if let Some(body) = writeback_body {
s.push_str(&crate::view::render::render_output_card(line_no, body));
}
// Must close `.doc-block` — an early return left the wrapper open and
// nested the Functions/Variables outline under the document surface.
let band_annots: Vec<ViewAnnot> = annots
.iter()
.filter(|a| !is_noisy_result_chip(a))
.map(|a| (*a).clone())
.collect();
if !band_annots.is_empty() {
s.push_str(&render_annot_band(&band_annots, MAX_VISIBLE_ANNOTS));
}
s.push_str("</div>");
return s;
}
if bits.is_empty() {
@@ -1545,6 +1556,52 @@ When we meet `who`, we **print text="Hi, `who`!"** and close with*None*.
}
}
#[cfg(test)]
mod occl_render_tests {
use super::render_module_document;
fn div_balance(html: &str) -> i32 {
let mut depth = 0i32;
let b = html.as_bytes();
let mut i = 0usize;
while i + 3 < b.len() {
if b[i] == b'<' {
if i + 4 <= b.len() && &b[i..i + 4] == b"<div" && (b.get(i + 4) == Some(&b' ') || b.get(i + 4) == Some(&b'>')) {
depth += 1;
} else if i + 6 <= b.len() && &b[i..i + 6] == b"</div>" {
depth -= 1;
}
}
i += 1;
}
depth
}
#[test]
fn occlusion_line_closes_doc_block() {
let src = r#"---
markup: occlusion
---
# main
`v` = [描述](1)
"#;
let module = crate::parse::parse_source(src).unwrap();
let html = render_module_document(&module, src, &[]);
assert!(html.contains("doc-occl"), "{html}");
assert_eq!(
div_balance(&html),
0,
"occlusion must not leave .doc-block open: {html}"
);
assert!(
html.contains("doc-occl") && html.contains("</div></div>"),
"doc-block around occlusion must close: {html}"
);
}
}
#[cfg(test)]
mod occl_split_tests {
use super::split_occlusion;
+34 -2
View File
@@ -237,6 +237,11 @@ a:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
min-width: 0;
overflow: auto;
background: var(--bg);
/* Content-pane width (excludes file nav) drives outline stacking — not the
* viewport. A 960px viewport media query wrongly put Functions/Variables
* under a tall Structure while the left nav was still visible. */
container-type: inline-size;
container-name: mq-panel;
}
main.panel {
padding: 2rem 2.25rem 3.5rem;
@@ -719,9 +724,17 @@ body.notebook-page .exec-clear:hover { border-color: var(--nb-accent); color: va
gap: 0.75rem;
align-items: start;
}
@media (max-width: 960px) {
/* Stack only when the *panel* is too narrow for Structure + outline rail.
* Prefer keeping the rail beside the doc at tablet widths (matches ≤800px
* shell collapse in doc/design/view.md). When stacked, pull the rail above
* so it is not buried under a long document. */
@container mq-panel (max-width: 32rem) {
.struct-wrap { grid-template-columns: 1fr; }
.outline-rail, .outline-panel { position: static; }
.outline-rail {
order: -1;
position: static;
}
.outline-panel { position: static; }
}
.outline-rail {
position: sticky;
@@ -4527,6 +4540,25 @@ mod plan_card_tests {
mod tests {
use super::*;
#[test]
fn outline_rail_stacks_by_panel_container_not_960_viewport() {
let css = stylesheet();
assert!(
css.contains("container-name: mq-panel"),
"panel-wrap should be a size container for outline layout"
);
assert!(
css.contains("@container mq-panel (max-width: 32rem)"),
"outline must stack from panel width, not a mid-width viewport media query"
);
assert!(
!css.contains("@media (max-width: 960px) {\n .struct-wrap"),
"960px viewport media wrongly buried the outline under Structure"
);
let html = layout("t", "<p>nav</p>", "<p>main</p>");
assert!(html.contains("container-name: mq-panel"), "{html}");
}
#[test]
fn notebook_ui_has_controls() {
let ui = notebook_ui();