]> git.lyx.org Git - features.git/commitdiff
FindAdv: Remove left over comment character
authorKornel Benko <kornel@lyx.org>
Fri, 16 Nov 2018 11:12:06 +0000 (12:12 +0100)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 18 Jun 2020 12:39:51 +0000 (14:39 +0200)
Sometimes language spec starts with "% ". This happens in Japaneese documents
containig English text at start of paragraph.

src/lyxfind.cpp

index a5ea0c03944e84113ff19c0d2451ac23e7f4b018..44a46f9e0953b44067fd5866a889664fe04667b7 100644 (file)
@@ -1280,6 +1280,7 @@ class LatexInfo {
       return entries[keyinfo];
   };
   void setForDefaultLang(int upTo) {interval.setForDefaultLang(upTo);};
+  void addIntervall(int low, int up) { interval.addIntervall(low, up); };
 };
 
 
@@ -1921,6 +1922,8 @@ int LatexInfo::dispatch(ostringstream &os, int previousStart, KeyInfo &actual)
       break;
     }
     case KeyInfo::isMain: {
+      if (interval.par.substr(actual._dataStart, 2) == "% ")
+        interval.addIntervall(actual._dataStart, actual._dataStart+2);
       if (actual.disabled) {
         removeHead(actual);
         if ((interval.par.substr(actual._dataStart, 3) == " \\[") ||
@@ -2023,6 +2026,10 @@ string splitOnKnownMacros(string par, bool isPatternString) {
       firstKey = DummyKey;
       (void) li.setNextKey(firstkeyIdx);
     }
+    else {
+      if (par.substr(firstKey._dataStart, 2) == "% ")
+        li.addIntervall(firstKey._dataStart, firstKey._dataStart+2);
+    }
     nextkeyIdx = li.process(os, firstKey);
     while (nextkeyIdx >= 0) {
       // Check for a possible gap between the last
@@ -2631,13 +2638,13 @@ int findAdvFinalize(DocIterator & cur, MatchStringAdv const & match)
                old_match = 0;
        int prev_old_match = old_match;
        int old_len = len;
-       int step = 20;
+       int step = 200;
        int new_match;
        if (match.opt.matchword)
                step = 1;
-       while (step == 20) {
+       while (step > 4) {
                if (cur.pos() + len + step >= cur.lastpos()) {
-                       step = 1;
+                       step /= 5 ;
                        len = old_len;
                        old_match = prev_old_match;
                }
@@ -2650,7 +2657,7 @@ int findAdvFinalize(DocIterator & cur, MatchStringAdv const & match)
                                len += step;
                        }
                        else {
-                               step = 1;
+                               step /= 5;
                                len = old_len;
                                old_match = prev_old_match;
                        }