From faabefeca6300b7645a3f22e26534ae1e9ad07b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Fri, 29 Jan 2021 03:00:07 -0300 Subject: [PATCH] TextDocument: minor fix when saving files retaining undo/redo changes. ecode: Linter fix when file trimming is active. --- src/eepp/ui/doc/textdocument.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/eepp/ui/doc/textdocument.cpp b/src/eepp/ui/doc/textdocument.cpp index 0652693d1..ccda682a4 100644 --- a/src/eepp/ui/doc/textdocument.cpp +++ b/src/eepp/ui/doc/textdocument.cpp @@ -342,7 +342,7 @@ bool TextDocument::save( IOStream& stream, bool keepUndoRedoStatus ) { size_t lastLine = mLines.size() - 1; for ( size_t i = 0; i <= lastLine; i++ ) { std::string text( mLines[i].toUtf8() ); - if ( mTrimTrailingWhitespaces && text.size() > 1 && + if ( !keepUndoRedoStatus && mTrimTrailingWhitespaces && text.size() > 1 && whitespaces.find( text[text.size() - 2] ) != std::string::npos ) { size_t pos = text.find_last_not_of( whitespaces ); if ( pos != std::string::npos ) { @@ -362,7 +362,8 @@ bool TextDocument::save( IOStream& stream, bool keepUndoRedoStatus ) { if ( text.empty() ) continue; } - if ( mForceNewLineAtEndOfFile && !text.empty() && text[text.size() - 1] != '\n' ) { + if ( !keepUndoRedoStatus && mForceNewLineAtEndOfFile && !text.empty() && + text[text.size() - 1] != '\n' ) { text += "\n"; mLines.emplace_back( TextDocumentLine( "\n" ) ); notifyTextChanged();