*** empty log message ***
[m17n/m17n-lib-cs.git] / MText.cs
index 4f916f5..98cb0c5 100644 (file)
--- a/MText.cs
+++ b/MText.cs
@@ -53,7 +53,6 @@ namespace M17N.Core
     {
       this.key = key;
       this.val = val;
-      flags |= Flag.RearSticky;
     }
 
     public MTextProperty (MSymbol key, object val,
@@ -252,6 +251,8 @@ namespace M17N.Core
     {
       check_pos (pos, true);
 
+      if (from == to)
+       return;
       int pos_idx = pos_to_idx (this, pos);
       int from_idx = pos_to_idx (mt2, from);
       int to_idx = pos_to_idx (mt2, to);
@@ -596,12 +597,22 @@ namespace M17N.Core
 
       private MInterval LeftMost
       {
-       get { return (Left == null ? this : Left.LeftMost); }
+       get {
+         if (Left == null)
+           return this;
+         Left.update_from_to ();
+         return Left.LeftMost;
+       }
       }
 
       private MInterval RightMost
       {
-       get { return (Right == null ? this : Right.RightMost); }
+       get {
+         if (Right == null)
+           return this;
+         Right.update_from_to ();
+         return Right.RightMost;
+       }
       }
 
       private MInterval Prev {
@@ -609,12 +620,14 @@ namespace M17N.Core
          MInterval i;
 
          if (Left != null)
-           for (i = Left; i.Right != null; i = i.Right);
+           for (i = Left; i.Right != null; i = i.Right)
+             i.update_from_to ();
          else
            {
              MInterval child = this;
              for (i = Parent; i != null && i.Left == child;
-                  child = i, i = i.Parent);
+                  child = i, i = i.Parent)
+               i.update_from_to ();
            }
          return i;
        }
@@ -625,12 +638,14 @@ namespace M17N.Core
          MInterval i;
 
          if (Right != null)
-           for (i = Right; i.Left != null; i = i.Left);
+           for (i = Right; i.Left != null; i = i.Left)
+             i.update_from_to ();
          else
            {
              MInterval child = this;
              for (i = Parent; i != null && i.Right == child;
-                  child = i, i = i.Parent);
+                  child = i, i = i.Parent)
+               i.update_from_to ();
            }
          return i;
        }
@@ -978,7 +993,7 @@ namespace M17N.Core
       {
        update_from_to ();
        M17N.DebugPrint ("insert({0}) at {1} in ", interval.Length, pos);
-       DumpOne (false, true);
+       DumpOne (false, false);
 
        interval.set_mtext (mtext);
 
@@ -1097,6 +1112,7 @@ namespace M17N.Core
          }
        else                    // (pos > To)
          Next.Insert (pos, interval);
+       M17N.DebugPrint (" done\n");
       }
 
       private void vacate_node (MInterval interval)