diff --git a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/DefaultDocument.cs b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/DefaultDocument.cs index 6dab407120..cc5d73ce20 100644 --- a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/DefaultDocument.cs +++ b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/DefaultDocument.cs @@ -223,6 +223,7 @@ namespace ICSharpCode.TextEditor.Document OnDocumentAboutToBeChanged(new DocumentEventArgs(this, 0, 0, value)); textBufferStrategy.SetContent(value); lineTrackingStrategy.SetContent(value); + undoStack.ClearAll(); OnDocumentChanged(new DocumentEventArgs(this, 0, 0, value)); OnTextContentChanged(EventArgs.Empty); diff --git a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/IDocument.cs b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/IDocument.cs index b3135e4f33..5f9d983219 100644 --- a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/IDocument.cs +++ b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/IDocument.cs @@ -193,7 +193,10 @@ namespace ICSharpCode.TextEditor.Document #region ITextBufferStrategy interface /// - /// Get the whole text as string + /// Get the whole text as string. + /// When setting the text using the TextContent property, the undo stack is cleared. + /// Set TextContent only for actions such as loading a file; if you want to change the current document + /// use the Replace method instead. /// string TextContent { get; diff --git a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/TextEditorDisplayBinding.cs b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/TextEditorDisplayBinding.cs index cae8ae68d6..98d79967f7 100644 --- a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/TextEditorDisplayBinding.cs +++ b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/TextEditorDisplayBinding.cs @@ -209,7 +209,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor void SetText(string value) { - textAreaControl.Document.TextContent = value; + textAreaControl.Document.Replace(0, textAreaControl.Document.TextLength, value); } public string Text {