From 0ba84016830260491f5719f1c1ff0150cffc47b2 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 9 Jun 2023 18:26:02 +1000 Subject: [PATCH] autospell: use pane_too_long() to limit background work. Rather than an arbitrary count limit, use pane_too_long() to limit how much work is done in the background. But keep the low limit when TESTING so the test has something interesting too see. Signed-off-by: NeilBrown --- python/lib-autospell.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/python/lib-autospell.py b/python/lib-autospell.py index def56152..09c71f14 100644 --- a/python/lib-autospell.py +++ b/python/lib-autospell.py @@ -22,6 +22,7 @@ # a contiguous unchecked section in the range import edlib +import os def show_range(action, focus, viewnum, attr): edlib.LOG("range:", attr, action) @@ -274,11 +275,15 @@ class autospell_view(edlib.Pane): # nothing to do return edlib.Efail + self.set_time() focus = focus.leaf - remain = 20 + if 'EDLIB_TESTING' in os.environ: + remain = 20 + else: + remain = 200 ch = None - while start < end and remain > 0: + while start < end and remain > 0 and not self.too_long(): remain -= 1 ed = start.dup() focus.call("Spell:NextWord", ed) -- 2.39.5