Skip to content

Commit

Permalink
Only set the text when it is really new.
Browse files Browse the repository at this point in the history
  • Loading branch information
adeas31 committed Feb 19, 2016
1 parent 86b0320 commit e722f83
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions OMEdit/OMEditGUI/Editors/ModelicaTextEditor.cpp
Expand Up @@ -314,17 +314,27 @@ void ModelicaTextEditor::showContextMenu(QPoint point)
delete pMenu;
}

//! Reimplementation of QPlainTextEdit::setPlainText method.
//! Makes sure we dont update if the passed text is same.
//! @param text the string to set.
/*!
* \brief ModelicaTextEditor::setPlainText
* Reimplementation of QPlainTextEdit::setPlainText method.
* Makes sure we dont update if the passed text is same.
* \param text the string to set.
*/
void ModelicaTextEditor::setPlainText(const QString &text)
{
QMap<int, int> leadingSpacesMap;
QString contents = text;
// store and remove leading spaces
if (mpModelWidget->getLibraryTreeItem()->isInPackageOneFile()) {
leadingSpacesMap = StringHandler::getLeadingSpaces(contents);
contents = removeLeadingSpaces(contents);
} else {
mpPlainTextEdit->setPlainText(contents);
}
// Only set the text when it is really new
if (contents != mpPlainTextEdit->toPlainText()) {
mForceSetPlainText = true;
if (mpModelWidget->getLibraryTreeItem()->isInPackageOneFile()) {
QMap<int, int> leadingSpacesMap = StringHandler::getLeadingSpaces(contents);
contents = removeLeadingSpaces(contents);
mpPlainTextEdit->setPlainText(contents);
storeLeadingSpaces(leadingSpacesMap);
} else {
Expand Down

0 comments on commit e722f83

Please sign in to comment.