Browse Source

Fixed synchronization between OpenedFile.IsDirty and UndoStack.IsOriginalFile.

pull/12/head
Daniel Grunwald 15 years ago
parent
commit
d339654cdc
  1. 14
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/AvalonEditViewContent.cs

14
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/AvalonEditViewContent.cs

@ -57,7 +57,8 @@ namespace ICSharpCode.AvalonEdit.AddIn
void codeEditor_Document_UndoStack_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) void codeEditor_Document_UndoStack_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{ {
PrimaryFile.IsDirty = !codeEditor.Document.UndoStack.IsOriginalFile; if (!isLoading)
PrimaryFile.IsDirty = !codeEditor.Document.UndoStack.IsOriginalFile;
} }
void PrimaryFile_IsDirtyChanged(object sender, EventArgs e) void PrimaryFile_IsDirtyChanged(object sender, EventArgs e)
@ -126,13 +127,13 @@ namespace ICSharpCode.AvalonEdit.AddIn
} }
} }
//bool isLoading; bool isLoading;
public override void Load(OpenedFile file, Stream stream) public override void Load(OpenedFile file, Stream stream)
{ {
if (file != PrimaryFile) if (file != PrimaryFile)
return; return;
//isLoading = true; isLoading = true;
try { try {
BookmarksDetach(); BookmarksDetach();
codeEditor.PrimaryTextEditor.SyntaxHighlighting = codeEditor.PrimaryTextEditor.SyntaxHighlighting =
@ -143,11 +144,16 @@ namespace ICSharpCode.AvalonEdit.AddIn
} }
codeEditor.Load(stream); codeEditor.Load(stream);
// Load() causes the undo stack to think stuff changed, so re-mark the file as original if necessary
if (!this.PrimaryFile.IsDirty) {
codeEditor.Document.UndoStack.MarkAsOriginalFile();
}
// we set the file name after loading because this will place the fold markers etc. // we set the file name after loading because this will place the fold markers etc.
codeEditor.FileName = FileName.Create(file.FileName); codeEditor.FileName = FileName.Create(file.FileName);
BookmarksAttach(); BookmarksAttach();
} finally { } finally {
//isLoading = false; isLoading = false;
} }
} }

Loading…
Cancel
Save