From 7dfe5ec6a45ef90d189711b7101d040d46c5e4b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Sat, 28 Jan 2023 13:47:21 -0300 Subject: [PATCH] Fixed an issue when dragging minimap that caused the UI to not respond to mouse events. ecode: Added more LSP servers support (bash, HTML, Docker). Added textDocument/references message. --- bin/assets/plugins/lspclient.json | 21 +++++++++++++ include/eepp/ui/uicodeeditor.hpp | 2 ++ src/eepp/ui/doc/syntaxdefinitionmanager.cpp | 2 +- src/eepp/ui/uicodeeditor.cpp | 31 ++++++++++--------- .../ecode/plugins/lsp/lspclientserver.cpp | 26 +++++++++++++++- .../ecode/plugins/lsp/lspclientserver.hpp | 8 +++++ 6 files changed, 74 insertions(+), 16 deletions(-) diff --git a/bin/assets/plugins/lspclient.json b/bin/assets/plugins/lspclient.json index 9c15a830c..8ccddf041 100644 --- a/bin/assets/plugins/lspclient.json +++ b/bin/assets/plugins/lspclient.json @@ -140,6 +140,27 @@ "url": "https://github.com/dart-lang/sdk/blob/main/pkg/analysis_server/tool/lsp_spec", "command": "dart language-server --client-id ecode", "file_patterns": ["%.dart"] + }, + { + "language": "bash", + "name": "bash-language-server", + "url": "https://github.com/bash-lsp/bash-language-server", + "command": "bash-language-server start", + "file_patterns": ["%.sh", "%.bash"] + }, + { + "language": "html", + "name": "vscode-html-languageserver", + "url": "https://github.com/vscode-langservers/vscode-html-languageserver-bin", + "command": "html-languageserver --stdio", + "file_patterns": ["%.htm", "%.html"] + }, + { + "language": "dockerfile", + "name": "docker-langserver", + "url": "https://github.com/rcjsuen/dockerfile-language-server-nodejs", + "command": "docker-langserver --stdio", + "file_patterns": ["^[Cc]ontainerfile$", "^[dD]ockerfile$"] } ] } diff --git a/include/eepp/ui/uicodeeditor.hpp b/include/eepp/ui/uicodeeditor.hpp index 13aed1037..e4c804af2 100644 --- a/include/eepp/ui/uicodeeditor.hpp +++ b/include/eepp/ui/uicodeeditor.hpp @@ -847,6 +847,8 @@ class EE_API UICodeEditor : public UIWidget, public TextDocument::Client { bool topSpaceExists( UICodeEditorPlugin* plugin ) const; bool createContextMenu(); + + bool stopMinimapDragging( const Vector2f& mousePos ); }; }} // namespace EE::UI diff --git a/src/eepp/ui/doc/syntaxdefinitionmanager.cpp b/src/eepp/ui/doc/syntaxdefinitionmanager.cpp index 2a5946e49..fca7b8658 100644 --- a/src/eepp/ui/doc/syntaxdefinitionmanager.cpp +++ b/src/eepp/ui/doc/syntaxdefinitionmanager.cpp @@ -3020,7 +3020,7 @@ void SyntaxDefinitionManager::addJSX() { void SyntaxDefinitionManager::addContainerfile() { add( { "Containerfile", - { "^[Cc]ontainerfile$", "^[dD]ockerfile$", "%.[cC]ontainerfile$", "%.[dD]ockerfile$" }, + { "^[Cc]ontainerfile$", "^[dD]ockerfile$" }, { { { "#.*\n" }, "comment" }, { { "%[", "%]" }, "string" }, { { "%sas%s" }, "literal" }, diff --git a/src/eepp/ui/uicodeeditor.cpp b/src/eepp/ui/uicodeeditor.cpp index c1741f634..28b706152 100644 --- a/src/eepp/ui/uicodeeditor.cpp +++ b/src/eepp/ui/uicodeeditor.cpp @@ -355,13 +355,7 @@ void UICodeEditor::scheduledUpdate( const Time& ) { if ( mMouseDown ) { if ( !( getUISceneNode()->getWindow()->getInput()->getPressTrigger() & EE_BUTTON_LMASK ) ) { - if ( mMinimapDragging ) { - mMinimapDragging = false; - getEventDispatcher()->setNodeDragging( NULL ); - mVScrollBar->setEnabled( true ); - getUISceneNode()->setCursor( Cursor::Arrow ); - updateMipmapHover( getUISceneNode()->getWindow()->getInput()->getMousePosf() ); - } + stopMinimapDragging( getUISceneNode()->getWindow()->getInput()->getMousePosf() ); mMouseDown = false; getUISceneNode()->getWindow()->getInput()->captureMouse( false ); } else if ( !isMouseOverMeOrChilds() || mMinimapDragging ) { @@ -834,6 +828,9 @@ Uint32 UICodeEditor::onFocus() { } Uint32 UICodeEditor::onFocusLoss() { + if ( mMouseDown ) + getUISceneNode()->getWindow()->getInput()->captureMouse( false ); + stopMinimapDragging( getUISceneNode()->getWindow()->getInput()->getMousePosf() ); mMouseDown = false; mCursorVisible = false; getSceneNode()->getWindow()->stopTextInput(); @@ -1199,13 +1196,7 @@ Uint32 UICodeEditor::onMouseUp( const Vector2i& position, const Uint32& flags ) mMinimapEnabled && getMinimapRect( getScreenStart() ).contains( position.asFloat() ); if ( flags & EE_BUTTON_LMASK ) { - if ( mMinimapDragging ) { - mMinimapDragging = false; - getEventDispatcher()->setNodeDragging( NULL ); - mVScrollBar->setEnabled( true ); - getUISceneNode()->setCursor( Cursor::Arrow ); - updateMipmapHover( position.asFloat() ); - } + stopMinimapDragging( position.asFloat() ); if ( mMouseDown ) { mMouseDown = false; @@ -3446,4 +3437,16 @@ void UICodeEditor::invalidateLinesCache() { } } +bool UICodeEditor::stopMinimapDragging( const Vector2f& mousePos ) { + if ( mMinimapDragging ) { + mMinimapDragging = false; + getEventDispatcher()->setNodeDragging( NULL ); + mVScrollBar->setEnabled( true ); + getUISceneNode()->setCursor( Cursor::Arrow ); + updateMipmapHover( mousePos ); + return true; + } + return false; +} + }} // namespace EE::UI diff --git a/src/tools/ecode/plugins/lsp/lspclientserver.cpp b/src/tools/ecode/plugins/lsp/lspclientserver.cpp index 48b505fb8..82d2bf0b4 100644 --- a/src/tools/ecode/plugins/lsp/lspclientserver.cpp +++ b/src/tools/ecode/plugins/lsp/lspclientserver.cpp @@ -195,6 +195,12 @@ static json textDocumentPositionParams( const URI& document, TextPosition pos ) return params; } +static json referenceParams( const URI& document, TextPosition pos, bool decl ) { + auto params = textDocumentPositionParams( document, pos ); + params["context"] = json{ { "includeDeclaration", decl } }; + return params; +} + static json toJson( const std::vector& positions ) { json result; for ( const auto& position : positions ) @@ -356,7 +362,7 @@ static std::vector parseDocumentSymbols( const json& resul } }; - const auto symInfos = result; + const auto& symInfos = result; for ( const auto& info : symInfos ) parseSymbol( info, nullptr ); return ret; @@ -1504,6 +1510,24 @@ LSPClientServer::selectionRange( const URI& document, const std::vector>; using SelectionRangeHandler = ReplyHandler>>; using SignatureHelpHandler = ReplyHandler; + using LocationHandler = ReplyHandler>; class LSPRequestHandle : public PluginRequestHandle { public: @@ -144,6 +145,9 @@ class LSPClientServer { LSPRequestHandle documentHover( const URI& document, const TextPosition& pos, const HoverHandler& h ); + LSPRequestHandle documentReferences( const URI& document, const TextPosition& pos, bool decl, + const JsonReplyHandler& h ); + LSPRequestHandle documentCompletion( const URI& document, const TextPosition& pos, const JsonReplyHandler& h ); @@ -176,6 +180,10 @@ class LSPClientServer { void removeDoc( TextDocument* doc ); + LSPClientServer::LSPRequestHandle documentReferences( const URI& document, + const TextPosition& pos, bool decl, + const LocationHandler& h ); + protected: LSPClientServerManager* mManager{ nullptr }; String::HashType mId;