diff --git a/BeWo/View/Detail/VorlageEditView.xaml.cs b/BeWo/View/Detail/VorlageEditView.xaml.cs index 62f4b92fc..94ba8a856 100644 --- a/BeWo/View/Detail/VorlageEditView.xaml.cs +++ b/BeWo/View/Detail/VorlageEditView.xaml.cs @@ -260,11 +260,20 @@ namespace BeWo.View.Detail } private void TemplatesTreeView_MouseDoubleClick(object sender, MouseButtonEventArgs e) { - var selection = TreeListControlTemplates.SelectedItem as PlatzhalterVM; + var platzhalter = TreeListControlTemplates.SelectedItem as PlatzhalterVM; - if (selection.Platzhalter != null) + if (platzhalter.Platzhalter != null) { - EditorControl.Document.InsertText(EditorControl.Document.CaretPosition, "[" + selection.Platzhalter + "]"); + var doc = EditorControl.Document; + var selection = doc.Selection; + + if(selection.Length > 0) + { + doc.Delete(selection); + } + + var range = EditorControl.Document.InsertText(EditorControl.Document.CaretPosition, "[" + platzhalter.Platzhalter + "]"); + EditorControl.Document.Selection = range; } } }