From 4895f4815caff48593b5e04a3b3c639ff3db8fcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Sun, 6 Apr 2025 16:39:00 -0300 Subject: [PATCH] Should fix crash on copy paste if the pasted text is an empty string. --- src/eepp/ui/doc/textdocument.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 );