Browse Source

Fixed synchronization between OpenedFile.IsDirty and UndoStack.IsOriginalFile.

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

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

@ -57,6 +57,7 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -57,6 +57,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
void codeEditor_Document_UndoStack_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (!isLoading)
PrimaryFile.IsDirty = !codeEditor.Document.UndoStack.IsOriginalFile;
}
@ -126,13 +127,13 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -126,13 +127,13 @@ namespace ICSharpCode.AvalonEdit.AddIn
}
}
//bool isLoading;
bool isLoading;
public override void Load(OpenedFile file, Stream stream)
{
if (file != PrimaryFile)
return;
//isLoading = true;
isLoading = true;
try {
BookmarksDetach();
codeEditor.PrimaryTextEditor.SyntaxHighlighting =
@ -143,11 +144,16 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -143,11 +144,16 @@ namespace ICSharpCode.AvalonEdit.AddIn
}
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.
codeEditor.FileName = FileName.Create(file.FileName);
BookmarksAttach();
} finally {
//isLoading = false;
isLoading = false;
}
}

Loading…
Cancel
Save