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.
This commit is contained in:
Martín Lucas Golini
2023-01-28 13:47:21 -03:00
parent eb4943f1bd
commit 7dfe5ec6a4
6 changed files with 74 additions and 16 deletions
+21
View File
@@ -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$"]
}
]
}
+2
View File
@@ -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
+1 -1
View File
@@ -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" },
+17 -14
View File
@@ -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
@@ -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<TextPosition>& positions ) {
json result;
for ( const auto& position : positions )
@@ -356,7 +362,7 @@ static std::vector<LSPSymbolInformation> 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<TextPosi
} );
}
LSPClientServer::LSPRequestHandle LSPClientServer::documentReferences( const URI& document,
const TextPosition& pos,
bool decl,
const JsonReplyHandler& h ) {
auto params = referenceParams( document, pos, decl );
return send( newRequest( "textDocument/references", params ), h );
}
LSPClientServer::LSPRequestHandle LSPClientServer::documentReferences( const URI& document,
const TextPosition& pos,
bool decl,
const LocationHandler& h ) {
return documentReferences( document, pos, decl, [h]( const IdType& id, const json& json ) {
if ( h )
h( id, parseDocumentLocation( json ) );
} );
}
LSPClientServer::LSPRequestHandle
LSPClientServer::documentSemanticTokensFull( const URI& document, bool delta,
const std::string& requestId, const TextRange& range,
@@ -39,6 +39,7 @@ class LSPClientServer {
using SymbolInformationHandler = ReplyHandler<std::vector<LSPSymbolInformation>>;
using SelectionRangeHandler = ReplyHandler<std::vector<std::shared_ptr<LSPSelectionRange>>>;
using SignatureHelpHandler = ReplyHandler<LSPSignatureHelp>;
using LocationHandler = ReplyHandler<std::vector<LSPLocation>>;
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;