fix(injections): pin sibling priority regression
This commit is contained in:
parent
a231257894
commit
c3a57be3fa
|
|
@ -3078,9 +3078,15 @@ mod tests {
|
||||||
let pidfile = dir.path().join(format!("pid{round}"));
|
let pidfile = dir.path().join(format!("pid{round}"));
|
||||||
let mut sup = ProcessSupervisor::new();
|
let mut sup = ProcessSupervisor::new();
|
||||||
sup.set_group_term_grace(Duration::from_millis(300));
|
sup.set_group_term_grace(Duration::from_millis(300));
|
||||||
|
// Do not let the group leader exit until the background child has
|
||||||
|
// completed `setsid` and published its pid. Without this readiness
|
||||||
|
// gate, teardown can TERM the old process group before `setsid`
|
||||||
|
// runs; the child then dies before creating the pidfile (a race
|
||||||
|
// exposed consistently by the Ubuntu 20260714 runner image).
|
||||||
let script = format!(
|
let script = format!(
|
||||||
"setsid /bin/sh -c 'echo $$ > {}; exec sleep 30' & echo started",
|
"setsid /bin/sh -c 'echo $$ > {pid}; exec sleep 30' & \
|
||||||
pidfile.display()
|
while [ ! -s {pid} ]; do sleep 0.01; done; echo started",
|
||||||
|
pid = pidfile.display()
|
||||||
);
|
);
|
||||||
let id = sup.spawn(sh_group_spec("escapee", &script)).expect("spawn");
|
let id = sup.spawn(sh_group_spec("escapee", &script)).expect("spawn");
|
||||||
let ready = drain_until(&mut sup, id, Duration::from_secs(2), |evs| {
|
let ready = drain_until(&mut sup, id, Duration::from_secs(2), |evs| {
|
||||||
|
|
|
||||||
|
|
@ -1761,10 +1761,10 @@ fn scoped_style_spans(state: &EditorState, vp: &DeclaredViewport) -> Vec<StyleSp
|
||||||
// Collect the styled spans from every injection layer, scoping each
|
// Collect the styled spans from every injection layer, scoping each
|
||||||
// capture walk to the visible byte range so re-styling on each edit is
|
// capture walk to the visible byte range so re-styling on each edit is
|
||||||
// O(visible), not O(file) (framing Q#S6). Each span carries a priority
|
// O(visible), not O(file) (framing Q#S6). Each span carries a priority
|
||||||
// `(depth, order)`: a deeper layer wins over a shallower one, and
|
// `(layer_index, capture_order)`: a deeper layer wins over a shallower
|
||||||
// within a layer the wider-first order lets narrower captures override
|
// one, a later same-depth sibling wins over an earlier one, and within a
|
||||||
// (framing Q#IJ6). Fully-default styles are dropped (they fold as
|
// layer the wider-first order lets narrower captures override (framing
|
||||||
// identity anyway).
|
// Q#IJ6). Fully-default styles are dropped (they fold as identity anyway).
|
||||||
let mut styled: Vec<StyledLayerSpan> = Vec::new();
|
let mut styled: Vec<StyledLayerSpan> = Vec::new();
|
||||||
for (layer_idx, layer) in bundle.layers.iter().enumerate() {
|
for (layer_idx, layer) in bundle.layers.iter().enumerate() {
|
||||||
let Some(query) = layer.highlight_query.as_ref() else {
|
let Some(query) = layer.highlight_query.as_ref() else {
|
||||||
|
|
@ -1794,13 +1794,23 @@ fn scoped_style_spans(state: &EditorState, vp: &DeclaredViewport) -> Vec<StyleSp
|
||||||
start: s,
|
start: s,
|
||||||
end: e,
|
end: e,
|
||||||
style,
|
style,
|
||||||
priority: (layer_idx as u32, order as u32),
|
priority: layer_span_priority(layer_idx, layer.depth, order),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
flatten_layer_spans(&styled)
|
flatten_layer_spans(&styled)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type LayerSpanPriority = (u32, u32);
|
||||||
|
|
||||||
|
/// Build the total ordering shared by the wire flattener and its sibling
|
||||||
|
/// precedence regression test. Keeping the layer index and depth as separate
|
||||||
|
/// inputs makes the former `(depth, capture_order)` bug directly falsifiable:
|
||||||
|
/// two siblings tie on depth but must differ on layer index.
|
||||||
|
fn layer_span_priority(layer_index: usize, _depth: u16, capture_order: usize) -> LayerSpanPriority {
|
||||||
|
(layer_index as u32, capture_order as u32)
|
||||||
|
}
|
||||||
|
|
||||||
/// One styled span from a single injection layer, tagged with a priority
|
/// One styled span from a single injection layer, tagged with a priority
|
||||||
/// used to resolve overlaps: `(layer_index, capture_order)`, higher wins.
|
/// used to resolve overlaps: `(layer_index, capture_order)`, higher wins.
|
||||||
/// `layer_index` is the position in `bundle.layers` — depth-ascending, so a
|
/// `layer_index` is the position in `bundle.layers` — depth-ascending, so a
|
||||||
|
|
@ -1813,7 +1823,7 @@ struct StyledLayerSpan {
|
||||||
start: u64,
|
start: u64,
|
||||||
end: u64,
|
end: u64,
|
||||||
style: Style,
|
style: Style,
|
||||||
priority: (u32, u32),
|
priority: LayerSpanPriority,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Flatten possibly-overlapping per-layer styled spans into **disjoint**
|
/// Flatten possibly-overlapping per-layer styled spans into **disjoint**
|
||||||
|
|
@ -3543,19 +3553,27 @@ mod tests {
|
||||||
fg: Color::Indexed(2),
|
fg: Color::Indexed(2),
|
||||||
..Style::default()
|
..Style::default()
|
||||||
};
|
};
|
||||||
// Layer 0 span [0,10) red; layer 1 span [3,6) green (overlapping).
|
// Both spans are depth-1 siblings. Layer index 2 follows layer index
|
||||||
|
// 1, so green must win even though their depth/capture order tie.
|
||||||
|
let sibling_depth = 1;
|
||||||
|
let earlier = layer_span_priority(1, sibling_depth, 0);
|
||||||
|
let later = layer_span_priority(2, sibling_depth, 0);
|
||||||
|
assert!(
|
||||||
|
earlier < later,
|
||||||
|
"the later sibling has higher priority despite equal depth"
|
||||||
|
);
|
||||||
let styled = vec![
|
let styled = vec![
|
||||||
StyledLayerSpan {
|
StyledLayerSpan {
|
||||||
start: 0,
|
start: 0,
|
||||||
end: 10,
|
end: 10,
|
||||||
style: red,
|
style: red,
|
||||||
priority: (0, 0),
|
priority: earlier,
|
||||||
},
|
},
|
||||||
StyledLayerSpan {
|
StyledLayerSpan {
|
||||||
start: 3,
|
start: 3,
|
||||||
end: 6,
|
end: 6,
|
||||||
style: green,
|
style: green,
|
||||||
priority: (1, 0),
|
priority: later,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
let out = flatten_layer_spans(&styled);
|
let out = flatten_layer_spans(&styled);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue