]> git.lyx.org Git - lyx.git/blobdiff - src/lyxfind.cpp
Fix bug #12772
[lyx.git] / src / lyxfind.cpp
index 39543fa5ad2556940914b620520c1541e58bce18..6ccde78222d590aaaf8e603c2cc601537a77c0ba 100644 (file)
@@ -333,7 +333,7 @@ bool findOne(BufferView * bv, docstring const & searchstr,
 
        if (match_len > 0)
                bv->putSelectionAt(cur, match_len, !forward);
-       else if (onlysel) {
+       else if (onlysel && bv->cursor().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?"),
@@ -1123,10 +1123,10 @@ private:
        // 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;
@@ -3665,8 +3665,6 @@ MatchStringAdv::MatchStringAdv(lyx::Buffer & buf, FindAndReplaceOptions & opt)
        }
        // 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