From 1cbdf3ba0cc0a44e6b61cff2b0e89771d844724c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Mon, 8 Jul 2024 21:16:29 -0300 Subject: [PATCH] Try fix a weird crash with fold service. --- include/eepp/system/process.hpp | 2 +- src/eepp/graphics/text.cpp | 6 +++--- src/eepp/system/process.cpp | 2 +- .../ecode/plugins/lsp/lspclientserver.cpp | 4 ++++ .../ecode/plugins/lsp/lspclientserver.hpp | 2 ++ .../ecode/plugins/lsp/lspdocumentclient.cpp | 19 ++++++++++++------- .../ecode/plugins/lsp/lspdocumentclient.hpp | 2 ++ 7 files changed, 25 insertions(+), 12 deletions(-) diff --git a/include/eepp/system/process.hpp b/include/eepp/system/process.hpp index 25c5745b6..0afae89a9 100644 --- a/include/eepp/system/process.hpp +++ b/include/eepp/system/process.hpp @@ -218,7 +218,7 @@ class EE_API Process { void startShutdown(); /** Indicates if the process started its shutdown */ - const bool& isShuttingDown(); + bool isShuttingDown() const; protected: void* mProcess{ nullptr }; diff --git a/src/eepp/graphics/text.cpp b/src/eepp/graphics/text.cpp index 3f7dffec3..2ca6f8122 100644 --- a/src/eepp/graphics/text.cpp +++ b/src/eepp/graphics/text.cpp @@ -1768,11 +1768,11 @@ void Text::ensureGeometryUpdate() { Float vspace = static_cast( mFontStyleConfig.Font->getLineSpacing( mFontStyleConfig.CharacterSize ) ); Float x = 0.f; - Float y = static_cast( mFontStyleConfig.CharacterSize ); + Float y = mFontStyleConfig.CharacterSize; // Create one quad for each character - Float minX = static_cast( mFontStyleConfig.CharacterSize ); - Float minY = static_cast( mFontStyleConfig.CharacterSize ); + Float minX = mFontStyleConfig.CharacterSize; + Float minY = mFontStyleConfig.CharacterSize; Float maxX = 0.f; Float maxY = 0.f; Float maxW = 0.f; diff --git a/src/eepp/system/process.cpp b/src/eepp/system/process.cpp index 8e465fac7..03939016d 100644 --- a/src/eepp/system/process.cpp +++ b/src/eepp/system/process.cpp @@ -219,7 +219,7 @@ void Process::startShutdown() { mShuttingDown = true; } -const bool& Process::isShuttingDown() { +bool Process::isShuttingDown() const { return mShuttingDown; } diff --git a/src/tools/ecode/plugins/lsp/lspclientserver.cpp b/src/tools/ecode/plugins/lsp/lspclientserver.cpp index 5f51c7817..39f538c93 100644 --- a/src/tools/ecode/plugins/lsp/lspclientserver.cpp +++ b/src/tools/ecode/plugins/lsp/lspclientserver.cpp @@ -1308,6 +1308,10 @@ bool LSPClientServer::isRunning() { : ( mUsingSocket && mSocket != nullptr ); } +bool LSPClientServer::isReady() const { + return mReady; +} + void LSPClientServer::removeDoc( TextDocument* doc ) { Lock l( mClientsMutex ); if ( mClients.erase( doc ) > 0 ) { diff --git a/src/tools/ecode/plugins/lsp/lspclientserver.hpp b/src/tools/ecode/plugins/lsp/lspclientserver.hpp index b88086bbf..1337f3de5 100644 --- a/src/tools/ecode/plugins/lsp/lspclientserver.hpp +++ b/src/tools/ecode/plugins/lsp/lspclientserver.hpp @@ -72,6 +72,8 @@ class LSPClientServer { bool isRunning(); + bool isReady() const; + const LSPServerCapabilities& getCapabilities() const; LSPClientServerManager* getManager() const; diff --git a/src/tools/ecode/plugins/lsp/lspdocumentclient.cpp b/src/tools/ecode/plugins/lsp/lspdocumentclient.cpp index dbdec5325..8b5fbe000 100644 --- a/src/tools/ecode/plugins/lsp/lspdocumentclient.cpp +++ b/src/tools/ecode/plugins/lsp/lspdocumentclient.cpp @@ -18,6 +18,18 @@ LSPDocumentClient::LSPDocumentClient( LSPClientServer* server, TextDocument* doc notifyOpen(); requestSymbolsDelayed(); requestSemanticHighlightingDelayed(); + if ( mServer->isReady() ) + setupFoldRangeService(); +} + +void LSPDocumentClient::onServerInitialized() { + requestSymbols(); + requestSemanticHighlighting(); + setupFoldRangeService(); + // requestCodeLens(); +} + +void LSPDocumentClient::setupFoldRangeService() { mDoc->getFoldRangeService().setProvider( [this]( auto, bool requestFolds ) -> bool { return tryRequestFoldRanges( requestFolds ); } ); @@ -122,13 +134,6 @@ int LSPDocumentClient::getVersion() const { return mVersion; } -void LSPDocumentClient::onServerInitialized() { - requestSymbols(); - requestSemanticHighlighting(); - mDoc->getFoldRangeService().findRegions(); - // requestCodeLens(); -} - void LSPDocumentClient::refreshTag() { String::HashType oldTag = mTag; mTag = String::hash( mDoc->getURI().toString() ); diff --git a/src/tools/ecode/plugins/lsp/lspdocumentclient.hpp b/src/tools/ecode/plugins/lsp/lspdocumentclient.hpp index 95c8326b4..da8ad2c76 100644 --- a/src/tools/ecode/plugins/lsp/lspdocumentclient.hpp +++ b/src/tools/ecode/plugins/lsp/lspdocumentclient.hpp @@ -85,6 +85,8 @@ class LSPDocumentClient : public TextDocument::Client { void refreshTag(); + void setupFoldRangeService(); + UISceneNode* getUISceneNode(); void processTokens( LSPSemanticTokensDelta&& tokens, const Uint64& docModificationId );