Author: jpobst
Date: 2008-01-03 11:46:00 -0500 (Thu, 03 Jan 2008)
New Revision: 92189

Modified:
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Line.cs
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBox.cs
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextControl.cs
Log:
2008-01-03  Jonathan Pobst  <[EMAIL PROTECTED]>

        * Line.cs, RichTextBox.cs, TextControl.cs: Another awesome patch
        from Luke Page.  This one fixes bug #349926.

Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2008-01-03 16:30:09 UTC (rev 92188)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2008-01-03 16:46:00 UTC (rev 92189)
@@ -1,3 +1,8 @@
+2008-01-03  Jonathan Pobst  <[EMAIL PROTECTED]>
+
+       * Line.cs, RichTextBox.cs, TextControl.cs: Another awesome patch
+       from Luke Page.  This one fixes bug #349926.
+
 2007-12-30  Carlos Alberto Cortez <[EMAIL PROTECTED]>
 
        * CurrencyManager.cs: Actually fire the 2.0 ListChanged event when

Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Line.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Line.cs  
2008-01-03 16:30:09 UTC (rev 92188)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Line.cs  
2008-01-03 16:46:00 UTC (rev 92189)
@@ -244,7 +244,7 @@
                                return;
 
                        // Find the first tag that we are deleting from
-                       tag = FindTag (pos);
+                       tag = FindTag (pos + 1);
 
                        // Remove the characters from the line
                        text.Remove (pos, count);
@@ -348,7 +348,7 @@
                                pos = text.Length - 1;
 
                        while (tag != null) {
-                               if (((tag.Start - 1) <= pos) && (pos < 
(tag.Start + tag.Length - 1)))
+                               if (((tag.Start - 1) <= pos) && (pos <= 
(tag.Start + tag.Length - 1)))
                                        return LineTag.GetFinalTag (tag);
 
                                tag = tag.Next;

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBox.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBox.cs   
2008-01-03 16:30:09 UTC (rev 92188)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBox.cs   
2008-01-03 16:46:00 UTC (rev 92189)
@@ -535,16 +535,25 @@
                                LineTag end;
                                LineTag tag;
 
-                               start = document.selection_start.line.FindTag 
(document.selection_start.pos);
-                               end = document.selection_start.line.FindTag 
(document.selection_end.pos);
+                               if (selection_length > 0) {
+                                       start = 
document.selection_start.line.FindTag (document.selection_start.pos + 1);
+                                       end = 
document.selection_start.line.FindTag (document.selection_end.pos);
+                               } else {
+                                       start = 
document.selection_start.line.FindTag (document.selection_start.pos);
+                                       end = start;
+                               }
+
                                color = start.Color;
 
                                tag = start;
-                               while (tag != null && tag != end) {
+                               while (tag != null) {
 
                                        if (!color.Equals (tag.Color))
                                                return Color.Empty;
 
+                                       if (tag == end)
+                                               break;
+
                                        tag = document.NextTag (tag);
                                }
 
@@ -582,17 +591,26 @@
                                LineTag end;
                                LineTag tag;
 
-                               start = document.selection_start.line.FindTag 
(document.selection_start.pos);
-                               end = document.selection_start.line.FindTag 
(document.selection_end.pos);
+                               if (selection_length > 0) {
+                                       start = 
document.selection_start.line.FindTag (document.selection_start.pos + 1);
+                                       end = 
document.selection_start.line.FindTag (document.selection_end.pos);
+                               } else {
+                                       start = 
document.selection_start.line.FindTag (document.selection_start.pos);
+                                       end = start;
+                               }
+
                                font = start.Font;
 
                                if (selection_length > 1) {
                                        tag = start;
-                                       while (tag != null && tag != end) {
+                                       while (tag != null) {
 
                                                if (!font.Equals(tag.Font))
                                                        return null;
 
+                                               if (tag == end)
+                                                       break;
+
                                                tag = document.NextTag (tag);
                                        }
                                }

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextControl.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextControl.cs   
2008-01-03 16:30:09 UTC (rev 92188)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextControl.cs   
2008-01-03 16:46:00 UTC (rev 92189)
@@ -1013,7 +1013,7 @@
                                current_line = GetLine (start_line.LineNo + 
current_cumulative - 1);
 
                                // find the tag we start on
-                               LineTag current_tag = current_line.FindTag 
(index_found - (int)cumulative_length_list [current_cumulative - 1]);
+                               LineTag current_tag = current_line.FindTag 
(index_found - (int)cumulative_length_list [current_cumulative - 1] + 1);
 
                                if (current_tag.Start != (index_found - 
(int)cumulative_length_list [current_cumulative - 1]) + 1) {
                                        if (current_tag == CaretTag)
@@ -1034,6 +1034,7 @@
                                        if ((int)cumulative_length_list 
[current_cumulative] <= index_found + i) {
 
                                                current_line = GetLine 
(start_line.LineNo + current_cumulative++);
+                                               //todo - +1?
                                                current_tag = 
current_line.FindTag (index_found + i - (int)cumulative_length_list 
[current_cumulative - 1]);
 
                                                current_tag.IsLink = true;
@@ -2321,7 +2322,10 @@
                        if (move_sel_start) {
                                selection_start.line = new_line;
                                selection_start.pos = selection_start.pos - pos;
-                               selection_start.tag = 
new_line.FindTag(selection_start.pos);
+                               if  (selection_start.Equals(selection_end))
+                                       selection_start.tag = 
new_line.FindTag(selection_start.pos);
+                               else
+                                       selection_start.tag = new_line.FindTag 
(selection_start.pos + 1);
                        }
 
                        if (move_sel_end) {
@@ -2657,7 +2661,7 @@
                                                } else {
                                                        selection_start.line = 
selection_anchor.line;
                                                        selection_start.pos = 
selection_anchor.height;
-                                                       selection_start.tag = 
selection_anchor.line.FindTag(selection_anchor.height);
+                                                       selection_start.tag = 
selection_anchor.line.FindTag(selection_anchor.height + 1);
 
                                                        selection_end.line = 
caret.line;
                                                        selection_end.tag = 
caret.line.tags;
@@ -2688,7 +2692,7 @@
                                                }
                                                if (caret < selection_anchor) {
                                                        selection_start.line = 
caret.line;
-                                                       selection_start.tag = 
caret.line.FindTag(start_pos);
+                                                       selection_start.tag = 
caret.line.FindTag(start_pos + 1);
                                                        selection_start.pos = 
start_pos;
 
                                                        selection_end.line = 
selection_anchor.line;
@@ -2703,7 +2707,7 @@
                                                } else {
                                                        selection_start.line = 
selection_anchor.line;
                                                        selection_start.pos = 
selection_anchor.height;
-                                                       selection_start.tag = 
selection_anchor.line.FindTag(selection_anchor.height);
+                                                       selection_start.tag = 
selection_anchor.line.FindTag(selection_anchor.height + 1);
 
                                                        selection_end.line = 
caret.line;
                                                        selection_end.tag = 
caret.line.FindTag(end_pos);
@@ -2761,7 +2765,7 @@
                                                
this.Invalidate(selection_start.line, start_pos, caret.line, end_pos);
 
                                                selection_start.line = 
caret.line;
-                                               selection_start.tag = 
caret.line.FindTag(start_pos);
+                                               selection_start.tag = 
caret.line.FindTag(start_pos + 1);
                                                selection_start.pos = start_pos;
 
                                                selection_end.line = caret.line;
@@ -3050,7 +3054,7 @@
                                        DeleteChars (selection_start.line, 
selection_start.pos, selection_end.pos - selection_start.pos);
 
                                        // The tag might have been removed, we 
need to recalc it
-                                       selection_start.tag = 
selection_start.line.FindTag(selection_start.pos);
+                                       selection_start.tag = 
selection_start.line.FindTag(selection_start.pos + 1);
                                } else {
                                        int             start;
                                        int             end;
@@ -4272,7 +4276,7 @@
                                line.text = new StringBuilder 
(current.text.ToString (start, end - start));
 
                                // Copy tags from start to start+length onto 
new line
-                               current_tag = current.FindTag (start);
+                               current_tag = current.FindTag (start + 1);
                                while ((current_tag != null) && 
(current_tag.Start <= end)) {
                                        if ((current_tag.Start <= start) && 
(start < (current_tag.Start + current_tag.Length))) {
                                                // start tag is within this tag

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to