]> git.lyx.org Git - features.git/commitdiff
Add test for bug #12069
authorYuriy Skalko <yuriy.skalko@gmail.com>
Sat, 23 Jan 2021 22:46:00 +0000 (00:46 +0200)
committerYuriy Skalko <yuriy.skalko@gmail.com>
Wed, 10 Feb 2021 23:34:52 +0000 (01:34 +0200)
src/lyxfind.cpp
src/lyxfind.h
src/test/issues/12069.cpp [new file with mode: 0644]

index 092375c0879ced1e14895c3f771afbdae8013958..bc2b0746ed494f94465fe790321279bcea4a4995 100644 (file)
@@ -256,10 +256,12 @@ bool searchAllowed(docstring const & str)
        return true;
 }
 
+} // namespace
+
 
 bool findOne(BufferView * bv, docstring const & searchstr,
             bool case_sens, bool whole, bool forward,
-            bool find_del = true, bool check_wrap = false)
+            bool find_del, bool check_wrap)
 {
        if (!searchAllowed(searchstr))
                return false;
@@ -307,6 +309,8 @@ bool findOne(BufferView * bv, docstring const & searchstr,
 }
 
 
+namespace {
+
 int replaceAll(BufferView * bv,
               docstring const & searchstr, docstring const & replacestr,
               bool case_sens, bool whole)
index 30c1ddde0d13af75dce3f56684f811ad6d5a0778..00414f1ce7401bb61b4109b585f2ccb218f15115 100644 (file)
@@ -55,6 +55,10 @@ docstring const replace2string(docstring const & replace,
  */
 bool lyxfind(BufferView * bv, FuncRequest const & ev);
 
+bool findOne(BufferView * bv, docstring const & searchstr,
+            bool case_sens, bool whole, bool forward,
+            bool find_del = true, bool check_wrap = false);
+
 /** Parse the string encoding of the replace request that is found in
  *  \c ev.argument and act on it.
  * The string is encoded by \c replace2string.
diff --git a/src/test/issues/12069.cpp b/src/test/issues/12069.cpp
new file mode 100644 (file)
index 0000000..653c566
--- /dev/null
@@ -0,0 +1,20 @@
+#include <config.h>
+#include <doctest.h>
+
+#include "Buffer.h"
+#include "BufferView.h"
+#include "Changes.h"
+#include "Font.h"
+#include "lyxfind.h"
+#include "Paragraph.h"
+#include "Text.h"
+
+using namespace lyx;
+
+
+TEST_CASE("no false matches in deleted text") {
+       Buffer b("noname");
+       BufferView bv(b);
+       b.paragraphs()[0].insert(0, from_utf8("some text"), Font(), Change(Change::DELETED));
+       CHECK_FALSE(findOne(&bv, from_utf8("abc"), false, false, true, false, false));
+}