]> git.lyx.org Git - features.git/commitdiff
FindAdv: Fix #11496 -- too slow find
authorKornel Benko <kornel@lyx.org>
Mon, 25 Feb 2019 10:59:54 +0000 (11:59 +0100)
committerKornel Benko <kornel@lyx.org>
Mon, 25 Feb 2019 11:12:19 +0000 (12:12 +0100)
Also added some more macros to handle

src/lyxfind.cpp

index 033fd4c31c8f621c89cf2286ed89b2c670db4bc3..3d9781e1cb365a7b22fc5df2b3eb32ac627f02b4 100644 (file)
@@ -1845,7 +1845,7 @@ void LatexInfo::buildKeys(bool isPatternString)
   // Skip
   // makeKey("enskip|smallskip|medskip|bigskip|vfill", KeyInfo(KeyInfo::isChar, 0, false), isPatternString);
   // Custom space/skip, remove the content (== length value)
-  makeKey("vspace|hspace|mspace", KeyInfo(KeyInfo::noContent, 1, false), isPatternString);
+  makeKey("vspace|vspace*|hspace|hspace*|mspace", KeyInfo(KeyInfo::noContent, 1, false), isPatternString);
   // Found in fr/UserGuide.lyx
   makeKey("og|fg", KeyInfo(KeyInfo::isChar, 0, false), isPatternString);
   // quotes
@@ -1877,7 +1877,7 @@ void LatexInfo::buildKeys(bool isPatternString)
   makeKey("trianglerightpar|hexagonpar|starpar",   KeyInfo(KeyInfo::isStandard, 1, true), isPatternString);
   makeKey("triangleuppar|triangledownpar|droppar", KeyInfo(KeyInfo::isStandard, 1, true), isPatternString);
   makeKey("triangleleftpar|shapepar|dropuppar",    KeyInfo(KeyInfo::isStandard, 1, true), isPatternString);
-  makeKey("hphantom|footnote|shortcut|includegraphics",     KeyInfo(KeyInfo::isStandard, 1, true), isPatternString);
+  makeKey("hphantom|vphantom|footnote|shortcut|include|includegraphics",     KeyInfo(KeyInfo::isStandard, 1, true), isPatternString);
   makeKey("parbox", KeyInfo(KeyInfo::doRemove, 1, true), isPatternString);
   // like ('tiny{}' or '\tiny ' ... )
   makeKey("footnotesize|tiny|scriptsize|small|large|Large|LARGE|huge|Huge", KeyInfo(KeyInfo::isSize, 0, false), isPatternString);
@@ -3120,8 +3120,13 @@ int findForwardAdv(DocIterator & cur, MatchStringAdv & match)
                                        }
                                }
                                if (match_len2 >= 0) {
-                                       if (match_len2 == 0)
-                                               match_len_zero_count++;
+                                       if (match_len2 == 0) {
+                                               if (match_len_zero_count++ > 10) {
+                                                       // Omit loooong loops in long paragraphs
+                                                       LYXERR(Debug::FIND, "match_len2_zero_count: " << match_len_zero_count << ", match_len was " << match_len);
+                                                       break;
+                                               }
+                                       }
                                        else
                                                match_len_zero_count = 0;
                                }