Skip to content
This repository was archived by the owner on Oct 4, 2021. It is now read-only.

[SourceEditor2] Allow subclasses to modify loaded/saved text #646

Merged
merged 1 commit into from
Sep 18, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,11 @@ void DisposeErrorMarkers ()
messageBubbleCache = null;
}
}

protected virtual string ProcessSaveText (string text)
{
return text;
}

public override void Save (string fileName)
{
Expand Down Expand Up @@ -694,7 +699,7 @@ public void Save (string fileName, Encoding encoding)
try {
var writeEncoding = encoding;
var writeBom = hadBom;
var writeText = Document.Text;
var writeText = ProcessSaveText (Document.Text);
if (writeEncoding == null) {
if (this.encoding != null) {
writeEncoding = this.encoding;
Expand Down Expand Up @@ -821,6 +826,11 @@ void IEncodedTextContent.Load (string fileName, Encoding loadEncoding)
Load (fileName, loadEncoding);
}

protected virtual string ProcessLoadText (string text)
{
return text;
}

public void Load (string fileName, Encoding loadEncoding, bool reload = false)
{
// Handle the "reload" case.
Expand Down Expand Up @@ -848,6 +858,7 @@ public void Load (string fileName, Encoding loadEncoding, bool reload = false)
encoding = loadEncoding;
text = TextFileUtility.ReadAllText (fileName, loadEncoding, out hadBom);
}
text = ProcessLoadText (text);
if (reload) {
Document.Replace (0, Document.TextLength, text);
Document.DiffTracker.Reset ();
Expand Down