OSDN Git Service

SelectionChangedが同じパンドラー内で二回呼び出されることがあったので避けるようにした
authorkonekoneko <test2214@hotmail.co.jp>
Tue, 8 Nov 2016 16:26:57 +0000 (21:56 +0530)
committerkonekoneko <test2214@hotmail.co.jp>
Tue, 8 Nov 2016 16:26:57 +0000 (21:56 +0530)
Core/Controller.cs
Core/Document.cs
Core/EditView.cs

index 6a66384..c02471b 100644 (file)
@@ -55,7 +55,6 @@ namespace FooEditEngine
     {
         EditView View;
         Document _Document;
-        bool keepAnchor = false;
         
         public Controller(Document doc, EditView view)
         {
@@ -96,8 +95,6 @@ namespace FooEditEngine
 
         private void _Document_CaretChanged(object sender, EventArgs e)
         {
-            if (keepAnchor)
-                return;
             TextPoint pos = this.Document.CaretPostion;
             this.JumpCaret(pos.row, pos.col);
         }
@@ -500,7 +497,6 @@ namespace FooEditEngine
         /// <param name="alignWord">単語単位で移動するなら真。そうでないなら偽</param>
         public void MoveCaretHorizontical(int realLength, bool isSelected,bool alignWord = false)
         {
-            keepAnchor = true;
             for (int i = Math.Abs(realLength); i > 0; i--)
             {
                 bool MoveFlow = realLength > 0;
@@ -513,7 +509,6 @@ namespace FooEditEngine
             }
             this.View.AdjustCaretAndSrc(AdjustFlow.Col);
             this.SelectWithMoveCaret(isSelected);
-            keepAnchor = false;
         }
 
         void AlignNearestWord(bool MoveFlow)
@@ -544,12 +539,10 @@ namespace FooEditEngine
         /// <param name="isSelected"></param>
         public void MoveCaretVertical(int deltarow,bool isSelected)
         {
-            keepAnchor = true;
             for (int i = Math.Abs(deltarow); i > 0; i--)
                 this.MoveCaretVertical(deltarow > 0);
             this.View.AdjustCaretAndSrc(AdjustFlow.Both);
             this.SelectWithMoveCaret(isSelected);
-            keepAnchor = false;
         }
 
         /// <summary>
@@ -738,12 +731,10 @@ namespace FooEditEngine
         /// <param name="tp"></param>
         public void MoveCaretAndSelect(TextPoint tp)
         {
-            keepAnchor = true;
             int CaretPostion = this.View.GetIndexFromLayoutLine(tp);
             this.Document.Select(this.Document.AnchorIndex, CaretPostion - this.Document.AnchorIndex);
             this.View.JumpCaret(tp.row, tp.col);
             this.View.AdjustCaretAndSrc();
-            keepAnchor = false;
         }
 
         /// <summary>
index f826e1b..575667b 100644 (file)
@@ -439,6 +439,12 @@ namespace FooEditEngine
             }
         }
 
+        internal void SetCaretPostionWithoutEvent(TextPoint value)
+        {
+            if (this._CaretPostion != value)
+                this._CaretPostion = value;
+        }
+
         /// <summary>
         /// 選択範囲コレクション
         /// </summary>
index 94f5889..e40ba2e 100644 (file)
@@ -691,7 +691,8 @@ namespace FooEditEngine
                 }
             }
 
-            this.Document.CaretPostion = new TextPoint(row, col);
+            //イベント呼び出しの再入防止のため
+            this.Document.SetCaretPostionWithoutEvent(new TextPoint(row, col));
         }
 
         /// <summary>