diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog index 95668b5e91e6f..cb3a3462f50e8 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog @@ -1,3 +1,9 @@ +2006-10-11 Jackson Harper + + * TextControl.cs: Special case for setting selection end to + selection start, we basically kill the anchor. + - some todo comments. + 2006-10-11 Chris Toshok * Control.cs: switch to using an "invalid_region" to track which diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextControl.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextControl.cs index 63e2c06b81ec0..69e3f9fff913d 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextControl.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextControl.cs @@ -2168,6 +2168,7 @@ internal struct Marker { line.text.Insert(pos, s); tag.length += len; + // TODO: sometimes getting a null tag here when pasting ??? tag = tag.next; while (tag != null) { tag.start += len; @@ -3208,7 +3209,18 @@ internal struct Marker { } internal void SetSelectionEnd(Line end, int end_pos) { - if ((end.line_no < selection_anchor.line.line_no) || ((end == selection_anchor.line) && (end_pos <= selection_anchor.pos))) { + + if (end == selection_end.line && end_pos == selection_start.pos) { + selection_anchor.line = selection_start.line; + selection_anchor.tag = selection_start.tag; + selection_anchor.pos = selection_start.pos; + + selection_end.line = selection_start.line; + selection_end.tag = selection_start.tag; + selection_end.pos = selection_start.pos; + + selection_end_anchor = false; + } else if ((end.line_no < selection_anchor.line.line_no) || ((end == selection_anchor.line) && (end_pos <= selection_anchor.pos))) { selection_start.line = end; selection_start.tag = LineTag.FindTag(end, end_pos); selection_start.pos = end_pos; @@ -3235,6 +3247,7 @@ internal struct Marker { Invalidate(selection_start.line, selection_start.pos, selection_end.line, selection_end.pos); } else { selection_visible = false; + // ?? Do I need to invalidate here, tests seem to work without it, but I don't think they should :-s } } @@ -3351,6 +3364,7 @@ internal struct Marker { } } + Insert(selection_start.line, null, selection_start.pos, true, s); selection_end.line = selection_start.line;