Fixes for M-02 to M-14, G-01 to G-14, K-02 to K-04, X-04 to X-14, not yet reviewed

Committed before review so Windows and WSL builds can start.
Each fix was tested and mutation-checked here; the codex review
of each item is still to come, so tasks/BUGS.md stays unticked.

M-02 is mid-review: round 1 findings are fixed (apps/ely-mark/src/tally.rs).
K-01 stays deferred. The ElyMark window test mark-outside.sh failed
once at its crash-recovery step in the last run; not yet looked into.
This commit is contained in:
ZacharyZhang-NY committed 2026-10-10 02:29:19 -04:00
1 parent 6505f35669
commit d59159cea2
75 files changed
+1482 -354

No files matched your search

+21 -7
View File
@@ -15,8 +15,8 @@ pub use cell::{Cell, Function, Mark, Request};
use cell::{functions_of, marks_of, request_of, usage_of};
pub use parse::A11y;
use parse::{
Dialog, a11y_update, dialog_of, fonts_of, formula_text, found_of, rect_of, result_of, state_of,
tabs_of,
Dialog, Unreadable, a11y_update, dialog_of, fonts_of, formula_text, found_of, rect_of,
result_of, state_of, tabs_of,
};
/// LOK_CALLBACK kinds Ely reads.
@@ -205,22 +205,36 @@ unsafe extern "C" fn on_event(kind: i32, payload: *const c_char, data: *mut c_vo
signal().notify_all();
}
/// A rectangle payload; an unreadable one is a fault.
fn rect_in(batch: &mut Events, what: &str, text: &str) -> Option<Rect> {
rect_of(text).unwrap_or_else(|Unreadable| {
batch.faults.push(format!("an unreadable {what}: {text}"));
None
})
}
/// Folds one callback in; returns a dialog to close.
fn record(slot: &mut Slot, kind: i32, text: &str) -> Option<u32> {
let batch = &mut slot.batch;
match kind {
INVALIDATE_TILES => {
batch.generation += 1;
match rect_of(text) {
match rect_in(batch, "invalidation", text) {
Some(rect) => batch.rects.push(rect),
None => batch.all = true,
}
}
CURSOR => batch.cursor = rect_of(text),
SELECTION => batch.selection = text.split(';').filter_map(rect_of).collect(),
CURSOR => batch.cursor = rect_in(batch, "cursor", text),
SELECTION => {
let parts: Vec<&str> = text.split(';').collect();
batch.selection = parts
.into_iter()
.filter_map(|part| rect_in(batch, "selection", part))
.collect();
}
CURSOR_VISIBLE => batch.cursor_visible = text == "true",
GRAPHIC => {
batch.graphic = rect_of(text);
batch.graphic = rect_in(batch, "graphic selection", text);
batch.cropping = batch.graphic.is_some() && text.contains("\"isCropMode\": true");
}
STATE => {
@@ -247,7 +261,7 @@ fn record(slot: &mut Slot, kind: i32, text: &str) -> Option<u32> {
.push(format!("an unreadable search result: {text}")),
},
MENU => batch.menu = Some(text.to_string()),
CELL_CURSOR => batch.cell.cursor = rect_of(text),
CELL_CURSOR => batch.cell.cursor = rect_in(batch, "cell cursor", text),
CELL_FORMULA => batch.cell.formula = text.to_string(),
CELL_ADDRESS => batch.cell.address = text.to_string(),
REFERENCE_MARKS => match marks_of(text) {
+1 -1
View File
@@ -209,7 +209,7 @@ pub fn marks_of(text: &str) -> Option<Vec<Mark>> {
.iter()
.map(|mark| {
Some(Mark {
rect: super::parse::rect_of(mark["rectangle"].as_str()?)?,
rect: super::parse::rect_of(mark["rectangle"].as_str()?).ok()??,
color: u32::from_str_radix(mark["color"].as_str()?, 16).ok()?,
part: mark["part"].as_str()?.parse().ok()?,
})
+22 -10
View File
@@ -21,16 +21,19 @@ pub enum Dialog {
Titled { window: u32, title: String },
}
/// Parses "x, y, w, h" plus optional fields.
pub fn rect_of(text: &str) -> Option<Rect> {
let parts: Vec<i32> = text
.split(',')
.filter_map(|part| part.trim().parse().ok())
.collect();
match parts.as_slice() {
[x, y, w, h, ..] => Some((*x, *y, *w, *h)),
_ => None,
/// A payload that is neither a rectangle nor empty.
#[derive(Debug, PartialEq)]
pub struct Unreadable;
/// "x, y, w, h" and later fields; "EMPTY" is none.
pub fn rect_of(text: &str) -> Result<Option<Rect>, Unreadable> {
let text = text.trim();
if text.is_empty() || text.starts_with("EMPTY") {
return Ok(None);
}
let mut parts = text.split(',').map(|part| part.trim().parse::<i32>());
let mut next = || parts.next().and_then(Result::ok).ok_or(Unreadable);
Ok(Some((next()?, next()?, next()?, next()?)))
}
/// A search's matches, each by its first rectangle.
@@ -39,7 +42,7 @@ pub fn found_of(text: &str) -> Option<Vec<Rect>> {
json["searchResultSelection"]
.as_array()?
.iter()
.map(|found| rect_of(found["rectangles"].as_str()?.split(';').next()?))
.map(|found| rect_of(found["rectangles"].as_str()?.split(';').next()?).ok()?)
.collect()
}
@@ -189,6 +192,15 @@ pub fn a11y_update(a11y: &mut A11y, kind: i32, text: &str) {
mod tests {
use super::*;
#[test]
fn a_rectangle_reads_strictly() {
assert_eq!(rect_of("1, 2, 3, 4, 0, 5"), Ok(Some((1, 2, 3, 4))));
assert_eq!(rect_of("EMPTY, 0, 0"), Ok(None));
assert_eq!(rect_of(""), Ok(None));
assert_eq!(rect_of(r#"{"x": 1}, 2, 3, 4, 5"#), Err(Unreadable));
assert_eq!(rect_of("1, 2, 3"), Err(Unreadable));
}
#[test]
fn dont_care_states_read_as_mixed() {
let mixed = state_of(r#"{"commandName":".uno:Bold","dontcare":true}"#);
+6 -1
View File
@@ -400,7 +400,12 @@ fn with_doc<T>(id: u64, call: impl FnOnce(&Document) -> T) -> io::Result<T> {
/// The shown part, then each part's name and info.
fn sheets(doc: &Document) -> io::Result<Vec<u8>> {
let count = doc.parts();
let mut pack = Pack::new().u64(doc.part() as u64).u64(count as u64);
// -1 means no view shell: no list.
let unread = |what| io::Error::other(format!("the kernel gives no {what}"));
let current = u64::try_from(doc.part()).map_err(|_| unread("current part"))?;
let mut pack = Pack::new()
.u64(current)
.u64(u64::try_from(count).map_err(|_| unread("part count"))?);
for part in 0..count {
pack = pack.str(&doc.part_name(part)?).str(&doc.part_info(part)?);
}
+6 -4
View File
@@ -17,7 +17,7 @@ fn invalid(what: &str) -> io::Error {
io::Error::new(io::ErrorKind::InvalidInput, what.to_string())
}
/// Paints one tile after checking the geometry (LOK-03).
/// One tile and the generation it was painted at (LOK-03).
fn paint(unpack: &mut Unpack) -> io::Result<(u64, Vec<u8>)> {
let id = unpack.u64()?;
let (x, y, w, h) = (unpack.i64()?, unpack.i64()?, unpack.i64()?, unpack.i64()?);
@@ -36,6 +36,8 @@ fn paint(unpack: &mut Unpack) -> io::Result<(u64, Vec<u8>)> {
"bad tile geometry",
));
};
// Read first: an invalidation mid-paint must outdate it.
let generation = crate::events::generation(id);
let tile = with_doc(id, |doc| {
let mut tile = vec![0u8; len as usize];
doc.paint_rect(
@@ -45,7 +47,7 @@ fn paint(unpack: &mut Unpack) -> io::Result<(u64, Vec<u8>)> {
);
tile
})?;
Ok((id, tile))
Ok((generation, tile))
}
/// One slide's whole picture at the asked pixels.
@@ -74,8 +76,8 @@ pub(super) fn part_painted(unpack: &mut Unpack) -> io::Result<Vec<u8>> {
/// A painted tile behind its generation.
pub(super) fn painted(unpack: &mut Unpack) -> io::Result<Vec<u8>> {
let (id, tile) = paint(unpack)?;
let mut body = Pack::new().u64(crate::events::generation(id)).bytes();
let (generation, tile) = paint(unpack)?;
let mut body = Pack::new().u64(generation).bytes();
body.extend_from_slice(&tile);
Ok(body)
}