diff --git a/src/eepp/ui/doc/textdocument.cpp b/src/eepp/ui/doc/textdocument.cpp index 9bccc9acf..bf105a35e 100644 --- a/src/eepp/ui/doc/textdocument.cpp +++ b/src/eepp/ui/doc/textdocument.cpp @@ -1760,7 +1760,8 @@ void TextDocument::pasteText( String&& text ) { if ( text.find_first_of( '\r' ) != String::InvalidPos ) String::replaceAll( text, "\r", "" ); - if ( std::count( text.begin(), text.end(), '\n' ) == + if ( !text.empty() && + std::count( text.begin(), text.end(), '\n' ) == static_cast( mSelection.size() ) - 1 && text.back() != '\n' ) { std::vector textLines = text.split( '\n', true, false );