commit 0964ffb266d1628c0dfe6f452185688ee5ed120f
Author: Kornel Benko <[email protected]>
Date:   Fri Nov 16 12:12:06 2018 +0100

    FindAdv: Remove left over comment character
    
    Sometimes language spec starts with "% ". This happens in Japaneese 
documents
    containig English text at start of paragraph.
---
 src/lyxfind.cpp |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp
index a5ea0c0..44a46f9 100644
--- a/src/lyxfind.cpp
+++ b/src/lyxfind.cpp
@@ -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;
                        }

Reply via email to