From cc9430b8dc78636461e9fe5e928288c495c4c483 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Tue, 2 Jan 2007 22:02:44 +0000 Subject: [PATCH] Fixed SD2-1087: Setting IEditable.Text does not update undo stack git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.1@2262 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../Project/Src/Document/DefaultDocument.cs | 1 + .../ICSharpCode.TextEditor/Project/Src/Document/IDocument.cs | 5 ++++- .../Src/TextEditor/Gui/Editor/TextEditorDisplayBinding.cs | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) 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 {