diff --git a/include/eepp/ui/doc/textdocument.hpp b/include/eepp/ui/doc/textdocument.hpp index 765fce553..40d939d56 100644 --- a/include/eepp/ui/doc/textdocument.hpp +++ b/include/eepp/ui/doc/textdocument.hpp @@ -158,7 +158,7 @@ class EE_API TextDocument { LoadStatus reload(); - const UUID& getUUID() const; + const EE::System::UUID& getUUID() const; bool save(); @@ -671,7 +671,7 @@ class EE_API TextDocument { friend class TextUndoStack; friend class FoldRangeServive; - UUID mUUID; + EE::System::UUID mUUID; Uint64 mModificationId{ 0 }; TextUndoStack mUndoStack; std::string mFilePath; diff --git a/src/eepp/system/process.cpp b/src/eepp/system/process.cpp index d94e47b6d..4fd27afa3 100644 --- a/src/eepp/system/process.cpp +++ b/src/eepp/system/process.cpp @@ -306,7 +306,7 @@ size_t Process::readAll( std::string& buffer, bool readErr, Time timeout ) { readErr ? subprocess_read_stderr( PROCESS_PTR, buffer.data() + totalBytesRead, CHUNK_SIZE ) : subprocess_read_stdout( PROCESS_PTR, buffer.data() + totalBytesRead, CHUNK_SIZE ); - if ( n == 0 ) { + if ( n <= 0 ) { if ( !isAlive() || ( timeout != Time::Zero && clock.getElapsedTime() >= timeout ) ) break; continue; @@ -348,6 +348,14 @@ size_t Process::readAll( std::string& buffer, bool readErr, Time timeout ) { } } if ( pollfd.revents & ( POLLERR | POLLHUP | POLLNVAL ) ) { + if ( pollfd.revents & POLLHUP ) { + while ( ( n = read( pollfd.fd, buffer.data() + totalBytesRead, CHUNK_SIZE ) ) > + 0 ) { + totalBytesRead += n; + if ( totalBytesRead + CHUNK_SIZE > buffer.size() ) + buffer.resize( totalBytesRead + CHUNK_SIZE ); + } + } pollfd.fd = -1; continue; } @@ -392,7 +400,7 @@ void Process::startAsyncRead( ReadFn readStdOut, ReadFn readStdErr ) { while ( !mShuttingDown ) { n = subprocess_read_stderr( PROCESS_PTR, static_cast( &buffer[0] ), mBufferSize ); - if ( n == 0 ) + if ( n <= 0 ) break; if ( n < mBufferSize - 1 ) buffer[n] = '\0'; @@ -448,6 +456,18 @@ void Process::startAsyncRead( ReadFn readStdOut, ReadFn readStdErr ) { } } if ( pollfds[i].revents & ( POLLERR | POLLHUP | POLLNVAL ) ) { + if ( pollfds[i].revents & POLLHUP ) { + ssize_t n = 0; + while ( ( n = read( pollfds[i].fd, &buffer[0], mBufferSize ) ) > + 0 ) { + if ( n < static_cast( mBufferSize - 1 ) ) + buffer[n] = '\0'; + if ( fdIsStdOut[i] ) + mReadStdOutFn( buffer.c_str(), static_cast( n ) ); + else + mReadStdErrFn( buffer.c_str(), static_cast( n ) ); + } + } pollfds[i].fd = -1; continue; } diff --git a/src/eepp/ui/doc/textdocument.cpp b/src/eepp/ui/doc/textdocument.cpp index af6abe3ea..1c4cb0585 100644 --- a/src/eepp/ui/doc/textdocument.cpp +++ b/src/eepp/ui/doc/textdocument.cpp @@ -3834,7 +3834,7 @@ bool TextSearchParams::isEmpty() { return text.empty(); } -const UUID& TextDocument::getUUID() const { +const EE::System::UUID& TextDocument::getUUID() const { return mUUID; } diff --git a/src/tools/ecode/ecode.cpp b/src/tools/ecode/ecode.cpp index 069d08b02..3a00f28b6 100644 --- a/src/tools/ecode/ecode.cpp +++ b/src/tools/ecode/ecode.cpp @@ -1,3 +1,18 @@ +#include + +#ifdef ECODE_USE_BACKWARD +#if EE_PLATFORM == EE_PLATFORM_LINUX +#define BACKWARD_HAS_DW 1 +#endif +#include +#ifdef UUID +#undef UUID +#endif +#ifdef KEY_EXECUTE +#undef KEY_EXECUTE +#endif +#endif + #include "ecode.hpp" #include "featureshealth.hpp" #include "keybindingshelper.hpp" @@ -39,12 +54,6 @@ using namespace std::literals; namespace fs = std::filesystem; using json = nlohmann::json; -#ifdef ECODE_USE_BACKWARD -#if EE_PLATFORM == EE_PLATFORM_LINUX -#define BACKWARD_HAS_DW 1 -#endif -#include -#endif #if EE_PLATFORM == EE_PLATFORM_MACOS #include "macos/macos.hpp" #endif diff --git a/src/tools/ecode/plugins/aiassistant/chatui.cpp b/src/tools/ecode/plugins/aiassistant/chatui.cpp index 7780bfc8a..e84f06789 100644 --- a/src/tools/ecode/plugins/aiassistant/chatui.cpp +++ b/src/tools/ecode/plugins/aiassistant/chatui.cpp @@ -268,6 +268,7 @@ LLMChatUI::LLMChatUI( PluginManager* manager ) : mChatInput->getDocument().selectAll(); mChatInput->getDocument().textInput( String{} ); mChatInput->setFocus(); + mChatScrollView->getVerticalScrollBar()->setValue( 1 ); } ); setCmd( "ai-prompt", [this] { diff --git a/src/tools/ecode/plugins/git/git.cpp b/src/tools/ecode/plugins/git/git.cpp index ad2df3997..e44674813 100644 --- a/src/tools/ecode/plugins/git/git.cpp +++ b/src/tools/ecode/plugins/git/git.cpp @@ -454,11 +454,17 @@ std::vector Git::getAllBranchesAndTags( RefType ref, std::string_vi String::readBySeparator( std::string_view{ buf }, [&]( std::string_view line ) { auto branch = String::trim( String::trim( line, '\'' ), '\t' ); if ( ( ref & Head ) && String::startsWith( branch, "refs/heads/" ) ) { - branches.emplace_back( parseLocalBranch( branch ) ); + auto parsedBranch = parseLocalBranch( branch ); + if ( !parsedBranch.isEmpty() ) + branches.emplace_back( std::move( parsedBranch ) ); } else if ( ( ref & Remote ) && String::startsWith( branch, "refs/remotes/" ) ) { - branches.emplace_back( parseRemoteBranch( branch ) ); + auto parsedBranch = parseRemoteBranch( branch ); + if ( !parsedBranch.isEmpty() ) + branches.emplace_back( std::move( parsedBranch ) ); } else if ( ( ref & Tag ) && String::startsWith( branch, "refs/tags/" ) ) { - branches.emplace_back( parseTag( branch ) ); + auto parsedBranch = parseTag( branch ); + if ( !parsedBranch.isEmpty() ) + branches.emplace_back( std::move( parsedBranch ) ); } } ); } @@ -481,7 +487,8 @@ std::vector Git::getAllBranchesAndTags( RefType ref, std::string_vi newBranch.name = std::move( name ); newBranch.remote = String::format( "stash@{%llu}", id ); newBranch.date = date; - branches.emplace_back( std::move( newBranch ) ); + if ( !newBranch.isEmpty() ) + branches.emplace_back( std::move( newBranch ) ); id++; } } ); diff --git a/src/tools/ecode/plugins/git/git.hpp b/src/tools/ecode/plugins/git/git.hpp index 4057c9632..524cf9c24 100644 --- a/src/tools/ecode/plugins/git/git.hpp +++ b/src/tools/ecode/plugins/git/git.hpp @@ -232,6 +232,8 @@ class Git { bool gone{ false }; const char* typeStr() const { return refTypeToString( type ); } + + bool isEmpty() const { return name.empty(); } }; enum DiffMode { DiffHead, DiffStaged };