patches: review pass 4 - fix BUF_MODIFF->BUF_CHARS_MODIFF in P0007

P0007 (announce overlay candidates) incorrectly changed ensureTextCache
to use BUF_MODIFF, causing O(buffer-size) AX text rebuilds on every
font-lock pass.  Reverted to BUF_CHARS_MODIFF throughout.

P0008 (child frame) now cleanly adds only new functionality without
re-introducing BUF_OVERLAY_MODIFF or BUF_MODIFF.

All review blockers and major issues addressed:
- P0000: unbind_to on fall-through path
- P0001: block_input in ns_ax_buffer_text
- P0003: block_input in postCompletionAnnouncementForBuffer; [trims release]
- P0004: block_input in ns_ax_scan_interactive_spans; mojibake ---
- P0006: texinfo semicolons -> periods
- P0007: BUF_CHARS_MODIFF throughout ensureTextCache (no oscillation)
- P0008: childFrameLastBuffer=BVAR(b,name); no BUF_OVERLAY_MODIFF in
  ensureTextCache; voiceoverSetPoint init; cachedOverlayModiffForText removed

git am passes all 9 patches on Linux git 2.43.0.
This commit is contained in:
2026-03-02 19:36:23 +01:00
parent 6fd28e19a8
commit 010630f33d
9 changed files with 44 additions and 76 deletions

View File

@@ -1,4 +1,4 @@
From 92aec64d791200f54fcd756b5a07581a6c15d0cb Mon Sep 17 00:00:00 2001
From c1fa92dbf8caa6faffed7a0813c92bed2f983092 Mon Sep 17 00:00:00 2001
From: Daneel <daneel@sukany.cz>
Date: Mon, 2 Mar 2026 18:39:46 +0100
Subject: [PATCH 7/8] ns: announce overlay completion candidates for VoiceOver
@@ -18,8 +18,8 @@ ValueChanged; keep overlay_modiff out of ensureTextCache to prevent a
race where an AX query consumes the change before notification.
---
src/nsterm.h | 1 +
src/nsterm.m | 324 ++++++++++++++++++++++++++++++++++++++++++++-------
2 files changed, 286 insertions(+), 39 deletions(-)
src/nsterm.m | 318 +++++++++++++++++++++++++++++++++++++++++++++------
2 files changed, 283 insertions(+), 36 deletions(-)
diff --git a/src/nsterm.h b/src/nsterm.h
index 5746e9e9bd..21a93bc799 100644
@@ -34,7 +34,7 @@ index 5746e9e9bd..21a93bc799 100644
@property (nonatomic, assign) BOOL cachedMarkActive;
@property (nonatomic, copy) NSString *cachedCompletionAnnouncement;
diff --git a/src/nsterm.m b/src/nsterm.m
index 8a1bfd9eb1..7fa28222b6 100644
index 8a1bfd9eb1..523f79d235 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -7263,11 +7263,154 @@ Accessibility virtual elements (macOS / Cocoa only)
@@ -228,7 +228,7 @@ index 8a1bfd9eb1..7fa28222b6 100644
write section at the end needs synchronization to protect
against concurrent reads from AX server thread. */
eassert ([NSThread isMainThread]);
@@ -8005,25 +8149,16 @@ - (void)ensureTextCache
@@ -8005,24 +8149,15 @@ - (void)ensureTextCache
if (!b)
return;
@@ -247,30 +247,18 @@ index 8a1bfd9eb1..7fa28222b6 100644
- explicit announcements in postAccessibilityNotificationsForFrame).
- Including overlay_modiff would silently update cachedOverlayModiff
- and prevent the notification dispatch from detecting changes. */
- ptrdiff_t chars_modiff = BUF_CHARS_MODIFF (b);
+ ptrdiff_t modiff = BUF_MODIFF (b);
ptrdiff_t chars_modiff = BUF_CHARS_MODIFF (b);
ptrdiff_t pt = BUF_PT (b);
NSUInteger textLen = cachedText ? [cachedText length] : 0;
- if (cachedText && cachedTextModiff == chars_modiff
+ /* Cache validity: track BUF_MODIFF and buffer narrowing.
+ Do NOT track BUF_OVERLAY_MODIFF here --- overlay text is not
+ included in the cached AX text (it is handled separately via
+ explicit announcements). Including overlay_modiff would
+ silently update cachedOverlayModiff and prevent the
+ notification dispatch from detecting overlay changes. */
+ if (cachedText && cachedTextModiff == modiff
if (cachedText && cachedTextModiff == chars_modiff
&& cachedTextStart == BUF_BEGV (b)
&& pt >= cachedTextStart
&& (textLen == 0
@@ -8039,7 +8174,7 @@ included in the cached AX text (it is handled separately via
{
[cachedText release];
cachedText = [text retain];
- cachedTextModiff = chars_modiff;
+ cachedTextModiff = modiff;
cachedTextStart = start;
if (visibleRuns)
@@ -8108,7 +8243,7 @@ - (NSUInteger)accessibilityIndexForCharpos:(ptrdiff_t)charpos
/* Binary search: runs are sorted by charpos (ascending). Find the
run whose [charpos, charpos+length) range contains the target,