From 4389c994015bce48c70bb67c95ff5b2db68d1e81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Wed, 16 Oct 2024 12:06:17 -0300 Subject: [PATCH] Fix breadcrumb highlight. Minor nit for lnk files. --- src/tools/ecode/ecode.cpp | 16 +++++++++++++++- src/tools/ecode/ecode.hpp | 2 +- src/tools/ecode/plugins/lsp/lspclientplugin.cpp | 11 ++++++----- src/tools/ecode/plugins/lsp/lspclientplugin.hpp | 2 +- 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/tools/ecode/ecode.cpp b/src/tools/ecode/ecode.cpp index f3b08ce68..26f4309f9 100644 --- a/src/tools/ecode/ecode.cpp +++ b/src/tools/ecode/ecode.cpp @@ -2044,9 +2044,21 @@ void App::loadImageFromPath( const std::string& path ) { loadImageFromMedium( path, false ); } -void App::loadFileFromPath( +bool App::loadFileFromPath( std::string path, bool inNewTab, UICodeEditor* codeEditor, std::function onLoaded ) { + + if ( FileSystem::fileExtension( path ) == "lnk" ) { + auto target = Sys::getShortcutTarget( path ); + if ( !target.empty() ) { + if ( FileSystem::fileExists( target ) ) + path = target; + else + return false; + } else if ( !FileSystem::fileExists( path ) ) + return false; + } + if ( Image::isImageExtension( path ) && Image::isImage( path ) && FileSystem::fileExtension( path ) != "svg" ) { loadImageFromPath( path ); @@ -2070,6 +2082,8 @@ void App::loadFileFromPath( } } } + + return true; } void App::hideGlobalSearchBar() { diff --git a/src/tools/ecode/ecode.hpp b/src/tools/ecode/ecode.hpp index 650ff493a..4a10a89b6 100644 --- a/src/tools/ecode/ecode.hpp +++ b/src/tools/ecode/ecode.hpp @@ -85,7 +85,7 @@ class App : public UICodeEditorSplitter::Client { std::shared_ptr getThreadPool() const; - void loadFileFromPath( std::string path, bool inNewTab = true, + bool loadFileFromPath( std::string path, bool inNewTab = true, UICodeEditor* codeEditor = nullptr, std::function onLoaded = std::function() ); diff --git a/src/tools/ecode/plugins/lsp/lspclientplugin.cpp b/src/tools/ecode/plugins/lsp/lspclientplugin.cpp index c10be2171..ccd8d4f62 100644 --- a/src/tools/ecode/plugins/lsp/lspclientplugin.cpp +++ b/src/tools/ecode/plugins/lsp/lspclientplugin.cpp @@ -1795,9 +1795,10 @@ bool LSPClientPlugin::onMouseMove( UICodeEditor* editor, const Vector2i& positio const Uint32& flags ) { if ( mBreadcrumb ) { auto localPos( editor->convertToNodeSpace( position.asFloat() ) ); - if ( localPos.y < mPluginTopSpace && localPos.x < editor->getTopAreaWidth() ) { + if ( localPos.y < mPluginTopSpace && localPos.x < editor->getTopAreaWidth() && + localPos.x >= 0 ) { if ( !mHoveringBreadcrumb ) { - mHoveringBreadcrumb = true; + mHoveringBreadcrumb = editor; editor->invalidateDraw(); } getUISceneNode()->setCursor( Cursor::Hand ); @@ -1805,7 +1806,7 @@ bool LSPClientPlugin::onMouseMove( UICodeEditor* editor, const Vector2i& positio } } if ( mHoveringBreadcrumb ) { - mHoveringBreadcrumb = false; + mHoveringBreadcrumb = nullptr; editor->invalidateDraw(); } @@ -1849,7 +1850,7 @@ bool LSPClientPlugin::onMouseMove( UICodeEditor* editor, const Vector2i& positio bool LSPClientPlugin::onMouseLeave( UICodeEditor* editor, const Vector2i&, const Uint32& ) { if ( mHoveringBreadcrumb ) { - mHoveringBreadcrumb = false; + mHoveringBreadcrumb = nullptr; editor->invalidateDraw(); } @@ -1911,7 +1912,7 @@ void LSPClientPlugin::drawTop( UICodeEditor* editor, const Vector2f& screenStart } Color textColor( editor->getColorScheme().getEditorColor( - mHoveringBreadcrumb ? SyntaxStyleTypes::Text : SyntaxStyleTypes::LineNumber2 ) ); + mHoveringBreadcrumb == editor ? SyntaxStyleTypes::Text : SyntaxStyleTypes::LineNumber2 ) ); const auto& workspace = getManager()->getWorkspaceFolder(); if ( isPath && !workspace.empty() && String::startsWith( path, workspace ) ) path = path.substr( workspace.size() ); diff --git a/src/tools/ecode/plugins/lsp/lspclientplugin.hpp b/src/tools/ecode/plugins/lsp/lspclientplugin.hpp index ac529c6a1..7ed20ce0e 100644 --- a/src/tools/ecode/plugins/lsp/lspclientplugin.hpp +++ b/src/tools/ecode/plugins/lsp/lspclientplugin.hpp @@ -124,7 +124,7 @@ class LSPClientPlugin : public Plugin { bool mSilence{ false }; bool mTrimLogs{ false }; bool mBreadcrumb{ true }; - bool mHoveringBreadcrumb{ false }; + UICodeEditor* mHoveringBreadcrumb{ nullptr }; StyleSheetLength mBreadcrumbHeight{ "20dp" }; std::unordered_map mKeyBindings; /* cmd, shortcut */ UnorderedMap> mDelayedDocs;