diff --git a/include/eepp/ui/doc/textdocument.hpp b/include/eepp/ui/doc/textdocument.hpp index 81d37a54d..383a01a50 100644 --- a/include/eepp/ui/doc/textdocument.hpp +++ b/include/eepp/ui/doc/textdocument.hpp @@ -73,7 +73,6 @@ class EE_API TextDocument { typedef std::function DocumentCommand; typedef std::function DocumentRefCommand; - TextDocument( bool verbose = true ); ~TextDocument(); diff --git a/src/eepp/ui/doc/syntaxdefinitionmanager.cpp b/src/eepp/ui/doc/syntaxdefinitionmanager.cpp index 933c134da..944e4a6e0 100644 --- a/src/eepp/ui/doc/syntaxdefinitionmanager.cpp +++ b/src/eepp/ui/doc/syntaxdefinitionmanager.cpp @@ -665,7 +665,7 @@ static void addIni() { static void addMakefile() { SyntaxDefinitionManager::instance()->add( { "Makefile", - { "Makefile", "makefile", "%.mk$", "%.make$", "%.mak$" }, + { "^[Mm]akefile$", "%.mk$", "%.make$", "%.mak$", "^Makefile%.am$", "^Makefile%.in$" }, { { { "#.*\n" }, "comment" }, { { "[[.]]}" }, "normal" }, diff --git a/src/eepp/ui/doc/textdocument.cpp b/src/eepp/ui/doc/textdocument.cpp index 24c4caeec..71b7eff2e 100644 --- a/src/eepp/ui/doc/textdocument.cpp +++ b/src/eepp/ui/doc/textdocument.cpp @@ -1529,15 +1529,20 @@ std::vector TextDocument::autoCloseBrackets( const String& text ) { if ( !mAutoCloseBrackets || 1 != text.size() ) return {}; - size_t pos = 0xFFFFFFFF; + size_t pos = std::numeric_limits::max(); + bool isClose = false; + bool isSame = false; for ( size_t i = 0; i < mAutoCloseBracketsPairs.size(); i++ ) { - if ( text[0] == mAutoCloseBracketsPairs[i].first ) { + if ( text[0] == mAutoCloseBracketsPairs[i].first || + text[0] == mAutoCloseBracketsPairs[i].second ) { pos = i; + isClose = text[0] == mAutoCloseBracketsPairs[i].second; + isSame = mAutoCloseBracketsPairs[i].first == mAutoCloseBracketsPairs[i].second; break; } } - if ( pos == 0xFFFFFFFF ) + if ( pos == std::numeric_limits::max() ) return {}; std::vector inserted; @@ -1554,7 +1559,18 @@ std::vector TextDocument::autoCloseBrackets( const String& text ) { if ( sel.start().column() < (Int64)line( sel.start().line() ).size() ) { auto ch = line( sel.start().line() ).getText()[sel.start().column()]; - if ( ch == closeChar ) + + if ( isClose && ch == closeChar && + ( !isSame || + ( sel.start().column() - 1 >= 0 && + line( sel.start().line() ).getText()[sel.start().column() - 1] == + text[0] ) ) ) { + deleteTo( i, 1 ); + inserted.push_back( false ); + continue; + } + + if ( isClose && !isSame ) mustClose = false; } diff --git a/src/tools/ecode/plugins/lsp/lspclientserver.cpp b/src/tools/ecode/plugins/lsp/lspclientserver.cpp index 9d99c2338..256903897 100644 --- a/src/tools/ecode/plugins/lsp/lspclientserver.cpp +++ b/src/tools/ecode/plugins/lsp/lspclientserver.cpp @@ -1760,6 +1760,8 @@ void LSPClientServer::processRequest( const json& msg ) { } void LSPClientServer::readStdOut( const char* bytes, size_t n ) { + if ( mEnded ) + return; mReceive.append( bytes, n ); std::string& buffer = mReceive; @@ -1884,6 +1886,8 @@ void LSPClientServer::readStdOut( const char* bytes, size_t n ) { } void LSPClientServer::readStdErr( const char* bytes, size_t n ) { + if ( mEnded ) + return; mReceiveErr += std::string( bytes, n ); LSPShowMessageParams msg; const auto lastNewLineIndex = mReceiveErr.find_last_of( '\n' ); @@ -2214,21 +2218,36 @@ void LSPClientServer::documentSemanticTokensFull( const URI& document, bool delt } void LSPClientServer::shutdown() { - if ( mReady ) { - Log::info( "LSPClientServer:shutdown: %s", mLSP.name.c_str() ); - { - Lock l( mHandlersMutex ); - mHandlers.clear(); - } - sendSync( newRequest( "shutdown" ), [this]( const IdType&, const json& ) { - sendSync( newRequest( "exit" ) ); - { - std::lock_guard l( mShutdownMutex ); - mReady = false; - } - mShutdownCond.notify_all(); - } ); + if ( !mReady ) + return; + Log::info( "LSPClientServer:shutdown: %s", mLSP.name.c_str() ); + { + Lock l( mHandlersMutex ); + mHandlers.clear(); } + sendSync( newRequest( "shutdown" ), [this]( const IdType&, const json& ) { + sendSync( newRequest( "exit" ) ); + { + std::lock_guard l( mShutdownMutex ); + mReady = false; + } + mEnded = true; + + if ( mUsingProcess ) { + Clock clock; + bool waited = false; + while ( mProcess.isAlive() && clock.getElapsedTime().asMilliseconds() < 250.f ) { + Sys::sleep( Milliseconds( 10 ) ); + waited = true; + } + if ( waited ) { + Log::debug( "Waited \"%s\" LSP process to exit: %s", mLSP.name, + clock.getElapsedTime().toString() ); + } + } + + mShutdownCond.notify_all(); + } ); } bool LSPClientServer::supportsLanguage( const std::string& lang ) const { diff --git a/src/tools/ecode/plugins/lsp/lspclientserver.hpp b/src/tools/ecode/plugins/lsp/lspclientserver.hpp index 7fd1a93ed..06b6d8359 100644 --- a/src/tools/ecode/plugins/lsp/lspclientserver.hpp +++ b/src/tools/ecode/plugins/lsp/lspclientserver.hpp @@ -259,6 +259,7 @@ class LSPClientServer { Mutex mClientsMutex; Mutex mHandlersMutex; bool mReady{ false }; + bool mEnded{ false }; bool mUsingProcess{ false }; bool mUsingSocket{ false }; struct QueueMessage {