UICodeEditor: don't change cursor position on right click when there is a previous selection. Added getRelativeScreenPosition.

EventDispatcher now has callbacks for focus change.
ecode: Improved LSP textDocument/definition, declaration, implementation, typeDefinition when more than one result is returned, now it's possible to select which result to see. Added a keybindings migration mechanism that will allow to rebind keybindings if where using the default old keybinding (some keybindings aren't ideal, I'll start to rebind some commands).
This commit is contained in:
Martín Lucas Golini
2023-02-19 21:54:11 -03:00
parent 7f27b08b5a
commit 2b990b22de
12 changed files with 308 additions and 23 deletions

View File

@@ -75,6 +75,10 @@ static json newEmptyResult( const PluginIDType& id ) {
return j;
}
static json executeCommandParams( const std::string& command, const json& args ) {
return json{ { MEMBER_COMMAND, command }, { MEMBER_ARGUMENTS, args } };
}
static json newSuccessResult( const PluginIDType& id, bool success = true ) {
json j;
json res;
@@ -396,7 +400,7 @@ static std::vector<LSPSymbolInformation> parseWorkspaceSymbols( const json& res
const auto& location = symbol.at( MEMBER_LOCATION );
const auto& mrange = symbol.contains( MEMBER_RANGE ) ? symbol.at( MEMBER_RANGE )
: location.at( MEMBER_RANGE );
: location.at( MEMBER_RANGE );
auto containerName = symbol.value( "containerName", "" );
if ( !containerName.empty() )
@@ -1464,10 +1468,23 @@ void LSPClientServer::goToLocation( const json& res ) {
LSPClientServer::LSPRequestHandle LSPClientServer::getAndGoToLocation( const URI& document,
const TextPosition& pos,
const std::string& search ) {
const std::string& search,
const LocationHandler& h ) {
auto params = textDocumentPositionParams( document, pos );
return send( newRequest( search, params ),
[this]( const IdType&, const json& res ) { goToLocation( res ); } );
return send( newRequest( search, params ), [h]( const IdType& id, const json& json ) {
if ( h )
h( id, parseDocumentLocation( json ) );
} );
}
LSPClientServer::LSPRequestHandle LSPClientServer::getAndGoToLocation( const URI& document,
const TextPosition& pos,
const std::string& search ) {
return getAndGoToLocation( document, pos, search,
[&]( const IdType&, const std::vector<LSPLocation>& locs ) {
if ( !locs.empty() )
mManager->goToLocation( locs.front() );
} );
}
LSPClientServer::LSPRequestHandle LSPClientServer::documentDefinition( const URI& document,
@@ -1661,6 +1678,11 @@ LSPClientServer::LSPRequestHandle LSPClientServer::memoryUsage() {
} );
}
LSPClientServer::LSPRequestHandle LSPClientServer::executeCommand( const std::string& cmd,
const json& params ) {
return send( executeCommandParams( cmd, params ), []( const auto&, const auto& ) {} );
}
LSPClientServer::LSPRequestHandle
LSPClientServer::documentSemanticTokensFull( const URI& document, bool delta,
const std::string& requestId, const TextRange& range,