Findadv: Some glitches found while searching for English text in fr/UserGuide.lyx

Ignore \index
Handle \og and \bg as characters
Remove space in empty list-item (description or labeling)
This commit is contained in:
Kornel Benko 2018-11-04 21:41:04 +01:00
parent aa68dcefa0
commit 70e2f09c4f

View File

@ -1097,7 +1097,7 @@ int Intervall::previousNotIgnored(int start)
int idx = 0; /* int intervalls */ int idx = 0; /* int intervalls */
for (idx = ignoreidx; idx >= 0; --idx) { for (idx = ignoreidx; idx >= 0; --idx) {
if (start > borders[idx].upper) if (start > borders[idx].upper)
return(start); return start;
if (start >= borders[idx].low) if (start >= borders[idx].low)
start = borders[idx].low-1; start = borders[idx].low-1;
} }
@ -1110,7 +1110,7 @@ int Intervall::nextNotIgnored(int start)
int idx = 0; /* int intervalls */ int idx = 0; /* int intervalls */
for (idx = 0; idx <= ignoreidx; idx++) { for (idx = 0; idx <= ignoreidx; idx++) {
if (start < borders[idx].low) if (start < borders[idx].low)
return(start); return start;
if (start < borders[idx].upper) if (start < borders[idx].upper)
start = borders[idx].upper; start = borders[idx].upper;
} }
@ -1252,7 +1252,7 @@ class LatexInfo {
return true; return true;
} }
else else
return(false); return false;
}; };
int process(ostringstream &os, KeyInfo &actual); int process(ostringstream &os, KeyInfo &actual);
int dispatch(ostringstream &os, int previousStart, KeyInfo &actual); int dispatch(ostringstream &os, int previousStart, KeyInfo &actual);
@ -1283,11 +1283,11 @@ int Intervall::findclosing(int start, int end, char up = '{', char down = '}')
depth++; depth++;
} }
else if (c == down) { else if (c == down) {
if (depth == 0) return(i); if (depth == 0) return i;
--depth; --depth;
} }
} }
return(end); return end;
} }
class MathInfo { class MathInfo {
@ -1322,7 +1322,7 @@ class MathInfo {
} }
return false; return false;
} }
bool empty() { return(entries.empty()); }; bool empty() { return entries.empty(); };
size_t getEndPos() { size_t getEndPos() {
if (entries.empty() || (actualIdx >= entries.size())) { if (entries.empty() || (actualIdx >= entries.size())) {
return 0; return 0;
@ -1561,6 +1561,8 @@ void LatexInfo::buildKeys(bool isPatternString)
// Know charaters // Know charaters
// No split // No split
makeKey("backslash|textbackslash|textasciicircum|textasciitilde", KeyInfo(KeyInfo::isChar, 1, false), isPatternString); makeKey("backslash|textbackslash|textasciicircum|textasciitilde", KeyInfo(KeyInfo::isChar, 1, false), isPatternString);
// Found in fr/UserGuide.lyx
makeKey("og|fg", KeyInfo(KeyInfo::isChar, 0, false), isPatternString);
// Known macros to remove (including their parameter) // Known macros to remove (including their parameter)
// No split // No split
@ -1568,7 +1570,7 @@ void LatexInfo::buildKeys(bool isPatternString)
// Macros to remove, but let the parameter survive // Macros to remove, but let the parameter survive
// No split // No split
makeKey("url|href|menuitem|footnote|code", KeyInfo(KeyInfo::isStandard, 1, true), isPatternString); makeKey("url|href|menuitem|footnote|code|index", KeyInfo(KeyInfo::isStandard, 1, true), isPatternString);
// Same effect as previous, parameter will survive (because there is no one anyway) // Same effect as previous, parameter will survive (because there is no one anyway)
// No split // No split
@ -1782,8 +1784,20 @@ int LatexInfo::dispatch(ostringstream &os, int previousStart, KeyInfo &actual)
// Discard extra parentheses '[]' // Discard extra parentheses '[]'
if (interval.par[actual._dataEnd+1] == '[') { if (interval.par[actual._dataEnd+1] == '[') {
int posdown = interval.findclosing(actual._dataEnd+2, interval.par.length(), '[', ']'); int posdown = interval.findclosing(actual._dataEnd+2, interval.par.length(), '[', ']');
processRegion(actual._dataEnd+2, posdown);
interval.addIntervall(actual._dataEnd+1, actual._dataEnd+2); interval.addIntervall(actual._dataEnd+1, actual._dataEnd+2);
interval.addIntervall(posdown, posdown+1); interval.addIntervall(posdown, posdown+1);
int blk = interval.nextNotIgnored(actual._dataEnd+1);
if (blk > posdown) {
// Discard space after empty item
int count;
for (count = 0; count < 10; count++) {
if (interval.par[blk+count] != ' ')
break;
}
if (count > 0)
interval.addIntervall(blk, blk+count);
}
} }
nextKeyIdx = getNextKey(); nextKeyIdx = getNextKey();
break; break;
@ -1848,7 +1862,7 @@ int LatexInfo::dispatch(ostringstream &os, int previousStart, KeyInfo &actual)
break; break;
} }
} }
return(nextKeyIdx); return nextKeyIdx;
} }
int LatexInfo::process(ostringstream &os, KeyInfo &actual ) int LatexInfo::process(ostringstream &os, KeyInfo &actual )
@ -1954,8 +1968,11 @@ string splitOnKnownMacros(string par, bool isPatternString) {
// Handle the remaining // Handle the remaining
firstKey._dataStart = li.nextNotIgnored(firstKey._dataStart); firstKey._dataStart = li.nextNotIgnored(firstKey._dataStart);
firstKey._dataEnd = par.length(); firstKey._dataEnd = par.length();
if (firstKey._dataStart < firstKey._dataEnd) if (firstKey._dataStart < firstKey._dataEnd) {
if (firstKey._tokensize > 0)
li.setForDefaultLang(firstKey._tokensize);
(void) li.process(os, firstKey); (void) li.process(os, firstKey);
}
s = os.str(); s = os.str();
} }
else else