mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-21 01:24:21 +00:00
Reverted CodeDocument::replaceAllContent, and added an applyChanges() method.
This commit is contained in:
parent
50e659a37b
commit
9a89d815cc
3 changed files with 13 additions and 2 deletions
|
|
@ -62,7 +62,7 @@ void SourceCodeDocument::reloadInternal()
|
|||
{
|
||||
jassert (codeDoc != nullptr);
|
||||
modDetector.updateHash();
|
||||
codeDoc->replaceAllContent (modDetector.getFile().loadFileAsString());
|
||||
codeDoc->applyChanges (modDetector.getFile().loadFileAsString());
|
||||
codeDoc->setSavePoint();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -574,7 +574,7 @@ void CodeDocument::replaceSection (const int start, const int end, const String&
|
|||
deleteSection (start + newTextLen, end + newTextLen);
|
||||
}
|
||||
|
||||
void CodeDocument::replaceAllContent (const String& newContent)
|
||||
void CodeDocument::applyChanges (const String& newContent)
|
||||
{
|
||||
TextDiff diff (getAllContent(), newContent);
|
||||
|
||||
|
|
@ -589,6 +589,12 @@ void CodeDocument::replaceAllContent (const String& newContent)
|
|||
}
|
||||
}
|
||||
|
||||
void CodeDocument::replaceAllContent (const String& newContent)
|
||||
{
|
||||
remove (0, getNumCharacters(), true);
|
||||
insert (newContent, 0, true);
|
||||
}
|
||||
|
||||
bool CodeDocument::loadFromStream (InputStream& stream)
|
||||
{
|
||||
remove (0, getNumCharacters(), false);
|
||||
|
|
|
|||
|
|
@ -234,6 +234,11 @@ public:
|
|||
*/
|
||||
void replaceAllContent (const String& newContent);
|
||||
|
||||
/** Analyses the changes between the current content and some new text, and applies
|
||||
those changes.
|
||||
*/
|
||||
void applyChanges (const String& newContent);
|
||||
|
||||
/** Replaces the editor's contents with the contents of a stream.
|
||||
This will also reset the undo history and save point marker.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue