diff options
author | Karl <karl@scowencomputers.co.nz> | 2015-09-11 13:01:32 +0300 |
---|---|---|
committer | Karl <karl@scowencomputers.co.nz> | 2020-01-13 06:42:44 +0300 |
commit | e01e43025d7da0eb8c28a8ddb075e51e82322ad3 (patch) | |
tree | ee7757f4d9559f5919ff8c8e9d71e003ba33e09c /mcs/class | |
parent | 1821cc8adfd3e1dc135c9dd7cb40f86a3058e96b (diff) |
Fix TextControl.ReplaceSelection to insert before removing so that setting SelectedText doesn't lose formatting.
Diffstat (limited to 'mcs/class')
-rw-r--r-- | mcs/class/System.Windows.Forms/System.Windows.Forms/TextControl.cs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/mcs/class/System.Windows.Forms/System.Windows.Forms/TextControl.cs b/mcs/class/System.Windows.Forms/System.Windows.Forms/TextControl.cs index 181dc2543b5..ffa4a7a160e 100644 --- a/mcs/class/System.Windows.Forms/System.Windows.Forms/TextControl.cs +++ b/mcs/class/System.Windows.Forms/System.Windows.Forms/TextControl.cs @@ -3234,7 +3234,12 @@ namespace System.Windows.Forms { int selection_start_pos = LineTagToCharIndex (selection_start.line, selection_start.pos); SuspendRecalc (); - // First, delete any selected text + if (!String.IsNullOrEmpty(s)) { + Insert(selection_start.line, selection_start.pos, false, s); + undo.RecordInsertString(selection_start.line, selection_start.pos, s); + } + + // Then delete any selected text if ((selection_start.pos != selection_end.pos) || (selection_start.line != selection_end.line)) { if (selection_start.line == selection_end.line) { undo.RecordDeleteString (selection_start.line, selection_start.pos, selection_end.line, selection_end.pos); @@ -3277,8 +3282,6 @@ namespace System.Windows.Forms { } - Insert(selection_start.line, selection_start.pos, false, s); - undo.RecordInsertString (selection_start.line, selection_start.pos, s); Line begin_update_line = selection_start.line; int begin_update_pos = selection_start.pos; |