]> git.neil.brown.name Git - edlib.git/commitdiff
autospell: use pane_too_long() to limit background work.
authorNeilBrown <neil@brown.name>
Fri, 9 Jun 2023 08:26:02 +0000 (18:26 +1000)
committerNeilBrown <neil@brown.name>
Wed, 28 Jun 2023 07:51:40 +0000 (17:51 +1000)
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 <neil@brown.name>
python/lib-autospell.py

index def56152a31f645a4e7e46b6102434740c4810be..09c71f14f1fa770977ea55b2ad8faab47d039348 100644 (file)
@@ -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)