]> granicus.if.org Git - vim/commitdiff
patch 9.0.0282: a nested timout stops the previous timeout v9.0.0282
authorBram Moolenaar <Bram@vim.org>
Fri, 26 Aug 2022 20:33:04 +0000 (21:33 +0100)
committerBram Moolenaar <Bram@vim.org>
Fri, 26 Aug 2022 20:33:04 +0000 (21:33 +0100)
Problem:    A nested timout stops the previous timeout.
Solution:   Ignore any nested timeout.

src/evalfunc.c
src/regexp.c
src/version.c

index a5f9ee359e0b9c572aee97003027e282a7d56ce8..d2cc8fc769555effdd21653c71eb73ac8f5e079c 100644 (file)
@@ -9176,7 +9176,8 @@ do_searchpair(
 
 theend:
 #ifdef FEAT_RELTIME
-    disable_regexp_timeout();
+    if (time_limit > 0)
+       disable_regexp_timeout();
 #endif
     vim_free(pat2);
     vim_free(pat3);
index bec046437f0ee7ad2fc8fb2321bd658066c9e3f2..8e6e9c44058a2a6f56c6f681a48dcd70fd46266c 100644 (file)
@@ -51,17 +51,32 @@ toggle_Magic(int x)
 }
 
 #ifdef FEAT_RELTIME
+static int timeout_nesting = 0;
+
+/*
+ * Start a timer that will cause the regexp to abort after "msec".
+ * This doesn't work well recursively.  In case it happens anyway, the first
+ * set timeout will prevail, nested ones are ignored.
+ * The caller must make sure there is a matching disable_regexp_timeout() call!
+ */
     void
 init_regexp_timeout(long msec)
 {
-    timeout_flag = start_timeout(msec);
+    if (timeout_nesting == 0)
+       timeout_flag = start_timeout(msec);
+    ++timeout_nesting;
 }
 
     void
 disable_regexp_timeout(void)
 {
-    stop_timeout();
-    timeout_flag = &dummy_timeout_flag;
+    if (timeout_nesting == 0)
+       iemsg("disable_regexp_timeout() called without active timer");
+    else if (--timeout_nesting == 0)
+    {
+       stop_timeout();
+       timeout_flag = &dummy_timeout_flag;
+    }
 }
 #endif
 
index ae33d6dac394e8aab3b4a73380cbf144baf0b573..2eb817cf9d2e73d602522722bf1a5694eb9b125d 100644 (file)
@@ -707,6 +707,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    282,
 /**/
     281,
 /**/