OSDN Git Service

最終行が空行だと全置換えに失敗するバグを修正した
authorkonekoneko <test2214@hotmail.co.jp>
Wed, 12 Oct 2016 10:45:59 +0000 (16:15 +0530)
committerkonekoneko <test2214@hotmail.co.jp>
Wed, 12 Oct 2016 10:45:59 +0000 (16:15 +0530)
Core/Document.cs
Core/StringBuffer.cs
WPF/UnitTest/DocumentTest.cs

index 0547e61..09b7c9b 100644 (file)
@@ -677,6 +677,19 @@ namespace FooEditEngine
             }
         }
 
+        /// <summary>
+        /// 再描写を要求しているなら真
+        /// </summary>
+        public bool IsRequestRedraw { get; internal set; }
+
+        /// <summary>
+        /// 再描写を要求する
+        /// </summary>
+        public void RequestRedraw()
+        {
+            this.IsRequestRedraw = true;
+        }
+
         public event EventHandler PerformLayouted;
         /// <summary>
         /// レイアウト行をすべて破棄し、再度レイアウトを行う
index 5e52bc5..4ff500c 100644 (file)
@@ -240,9 +240,11 @@ namespace FooEditEngine
                     else
                         return pattern;
                 });
-                this.Lock();
 
-                this.buf.RemoveRange(lineHeadIndex, lineLength);
+                this.Lock();
+                //空行は削除する必要はない
+                if(lineHeadIndex < this.buf.Count )
+                    this.buf.RemoveRange(lineHeadIndex, lineLength);
                 this.buf.InsertRange(lineHeadIndex, output, output.Length);
 
                 this.UnLock();
index 9cfbb4c..65fb5f0 100644 (file)
@@ -342,15 +342,29 @@ namespace UnitTest
         }
 
         [TestMethod]
-        public void ReplaceRegexAllTest()
+        public void ReplaceNonRegexAllTest()
         {
             DummyRender render = new DummyRender();
             Document doc = new Document();
             doc.LayoutLines.Render = render;
-            doc.Append("this is a pen");
+            doc.Append("this is a pen\n");
+            doc.Append("this is a pen\n");
             doc.SetFindParam("is", false, RegexOptions.None);
             doc.ReplaceAll("aaa", false);
-            Assert.IsTrue(doc.ToString(0) == "thaaa aaa a pen");
+            Assert.IsTrue(doc.ToString(0) == "thaaa aaa a pen\nthaaa aaa a pen\n");
+        }
+
+        [TestMethod]
+        public void ReplaceRegexAllTest()
+        {
+            DummyRender render = new DummyRender();
+            Document doc = new Document();
+            doc.LayoutLines.Render = render;
+            doc.Append("this is a pen\n");
+            doc.Append("this is a pen\n");
+            doc.SetFindParam("[a-z]+", true, RegexOptions.None);
+            doc.ReplaceAll("aaa", false);
+            Assert.IsTrue(doc.ToString(0) == "aaa aaa aaa aaa\naaa aaa aaa aaa\n");
         }
 
         [TestMethod]