From a90f764a8e64af48cbcbbf5bbfb2a5fd85e5d219 Mon Sep 17 00:00:00 2001 From: Eric Kaden <608341+EricKaden@users.noreply.github.com> Date: Sat, 24 Oct 2026 09:21:03 -0400 Subject: [PATCH] M6: app.runtimeHighlight asks once, for the setting a script ends with, under the request cap --- crates/js/src/lib.rs | 5 ++++- crates/js/src/tests.rs | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/js/src/lib.rs b/crates/js/src/lib.rs index 829143681e..fa56d1b177 100644 --- a/crates/js/src/lib.rs +++ b/crates/js/src/lib.rs @@ -690,7 +690,10 @@ fn set_runtime_highlight(_: &JsValue, args: &[JsValue], ctx: &mut Context) -> Js let mut h = host(ctx)?.borrow_mut(); if h.doc.highlight != on { h.doc.highlight = on; - h.requests.push(Request::Highlight(on)); + // Only the setting the script ends with matters: one request, the latest, under the + // host's request cap like any other. + h.requests.retain(|r| !matches!(r, Request::Highlight(_))); + h.request(Request::Highlight(on)); } Ok(JsValue::undefined()) } diff --git a/crates/js/src/tests.rs b/crates/js/src/tests.rs index 00450256ad..d29899125c 100644 --- a/crates/js/src/tests.rs +++ b/crates/js/src/tests.rs @@ -1560,6 +1560,10 @@ mod runtime_highlight { assert_eq!(o.error, None); assert_eq!(o.value, "false,true", "the script reads back what it set"); assert_eq!(o.requests, vec![Request::Highlight(true)]); + // A script that toggles it over and over asks once, for where it ended. + let o = go("for (var i = 0; i < 5001; i++) { app.runtimeHighlight = !app.runtimeHighlight; }", &ev); + assert_eq!(o.error, None); + assert_eq!(o.requests, vec![Request::Highlight(true)], "one request, the last setting"); } /// The same in XFA scripts, where the change is an effect; nothing is asked for when the