bool find_del, bool check_wrap, bool const auto_wrap,
bool instant, bool onlysel)
{
+ bool const had_selection = bv->cursor().selection();
+
// Clean up previous selections with empty searchstr on instant
if (searchstr.empty() && instant) {
- if (bv->cursor().selection()) {
+ if (had_selection) {
bv->setCursor(bv->cursor().selectionBegin());
bv->clearSelection();
}
if (!searchAllowed(searchstr))
return false;
- DocIterator const endcur = forward ? bv->cursor().selectionEnd() : bv->cursor().selectionBegin();
+ DocIterator const startcur = bv->cursor().selectionBegin();
+ DocIterator const endcur = bv->cursor().selectionEnd();
- if (onlysel && bv->cursor().selection()) {
+ if (onlysel && had_selection) {
docstring const matchstring = bv->cursor().selectionAsString(false);
docstring const lcmatchsting = support::lowercase(matchstring);
if (matchstring == searchstr || (!case_sens && lcmatchsting == lowercase(searchstr))) {
int match_len = forward
? findForward(cur, endcur, match, find_del, onlysel)
- : findBackwards(cur, endcur, match, find_del, onlysel);
+ : findBackwards(cur, startcur, match, find_del, onlysel);
if (match_len > 0)
bv->putSelectionAt(cur, match_len, !forward);
- else if (onlysel && bv->cursor().selection()) {
+ else if (onlysel && had_selection) {
docstring q = _("The search string was not found within the selection.\n"
"Continue search outside?");
int search_answer = frontend::Alert::prompt(_("Search outside selection?"),
return false;
}
else if (check_wrap) {
- DocIterator cur_orig(bv->cursor());
bool wrap = auto_wrap;
if (!auto_wrap) {
docstring q;
find_del, false, false, false, false))
return true;
}
- bv->cursor().setCursor(cur_orig);
+ bv->setCursor(startcur);
+
+ // restore original selection
+ if (had_selection) {
+ bv->cursor().resetAnchor();
+ bv->setSelection(startcur, endcur);
+ }
return false;
}
if (had_selection) {
endcur.fixIfBroken();
bv->cursor().resetAnchor();
- bv->setCursorSelectionTo(endcur);
+ bv->setSelection(startcur, endcur);
}
return num;
// normal blanks
blanks++;
}
- else if ((tempx[i] == '\302' && tempx[i+1] == '\240')
- || (tempx[i] == '\342' && tempx[i+1] == '\200')) {
- // protected space
- // thin space
+ else if (tempx[i] == '\302' && tempx[i+1] == '\240') {
+ // Normal Space
blanks++;
i++;
}
+ else if (tempx[i] == '\342') {
+ if (tempx[i+1] == '\200') {
+ if ((tempx[i+2] == '\257')
+ || (tempx[i+2] == '\203')
+ || (tempx[i+2] == '\202')) {
+ // Non-breaking Thin (1/6 em)
+ // Quad(1 em), (Double quad counts as 2 blanks)
+ // Half Quad
+ blanks++;
+ i += 2;
+ }
+ else if (tempx[i+2] == '\213') {
+ // Ignoring parts of Medium and Thick
+ i += 2;
+ continue;
+ }
+ else if ((tempx[i+2] == '\204') || (tempx[i+2] == '\205')) {
+ // Thick
+ // Medium
+ blanks++;
+ i += 2;
+ }
+ }
+ else if (tempx[i+1] == '\201') {
+ if (tempx[i+2] == '\240') {
+ // Ignoring parts of half quad
+ i += 2;
+ continue;
+ }
+ }
+ else if ((tempx[i+1] == '\220') && (tempx[i+2] == '\243')) {
+ // Visible space
+ blanks++;
+ i += 2;
+ }
+ }
else {
if (blanks > 0) {
temp += getRegexSpaceCount(blanks);
}
else if (sub.str(4) == "mathcircumflex")
replace = "^";
+ else if ((sub.str(4) == "negthinspace") || (sub.str(4) == "negmedspace") || (sub.str(4) == "negthickspace")) {
+ replace = accents[sub.str(4)+"{}"];
+ }
else if (backslashed) {
backslashed = false;
if (withformat) {
// par_as_string after removal of lead_as_string
string par_as_string_nolead;
// unmatched open braces in the search string/regexp
- int open_braces;
+ int open_braces = 0;
// number of (.*?) subexpressions added at end of search regexp for closing
// environments, math mode, styles, etc...
- int close_wildcards;
+ int close_wildcards = 0;
public:
// Are we searching with regular expressions ?
bool use_regexp = false;
accents["guillemotleft"] = "«";
accents["hairspace"] = getutf8(0xf0000); // select from free unicode plane 15
accents["thinspace"] = getutf8(0xf0002); // and used _only_ by findadv
- accents["negthinspace"] = getutf8(0xf0003); // to omit backslashed latex macros
+ accents["negthinspace{}"]= getutf8(0xf0003); // to omit backslashed latex macros
accents["medspace"] = getutf8(0xf0004); // See https://en.wikipedia.org/wiki/Private_Use_Areas
- accents["negmedspace"] = getutf8(0xf0005);
+ accents["negmedspace{}"] = getutf8(0xf0005);
accents["thickspace"] = getutf8(0xf0006);
- accents["negthickspace"] = getutf8(0xf0007);
+ accents["negthickspace{}"]= getutf8(0xf0007);
accents["lyx"] = getutf8(0xf0010); // Used logos
accents["LyX"] = getutf8(0xf0010);
accents["tex"] = getutf8(0xf0011);
if (accents.empty())
buildAccentsMap();
static regex const accre("\\\\("
- "([\\S]|[A-Za-z]+)\\{[^\\\\\\{\\}]+\\}"
+ "([\\S]|[A-Za-z]+)\\{[^\\\\\\{\\}]*\\}"
"|([\\S]|[A-Za-z]+)\\{\\\\[ij](math)?\\}"
"|("
"(backslash ([lL]y[xX]|[tT]e[xX]|[lL]a[tT]e[xX]e?|lyxarrow))"
}
// When using regexp, braces are hacked already by escape_for_regex()
par_as_string = convertLF2Space(ds, opt.ignoreformat);
- open_braces = 0;
- close_wildcards = 0;
size_t lead_size = 0;
// correct the language settings