diff --git a/include/eepp/ui/uitreeview.hpp b/include/eepp/ui/uitreeview.hpp index f2e23ea6b..cee72c6e7 100644 --- a/include/eepp/ui/uitreeview.hpp +++ b/include/eepp/ui/uitreeview.hpp @@ -89,7 +89,9 @@ class EE_API UITreeView : public UIAbstractTableView { virtual ModelIndex findRowWithText( const std::string& text, const bool& caseSensitive = false, const bool& exactMatch = false ) const; - virtual ModelIndex selectRowWithPath( std::string path ); + ModelIndex selectRowWithPath( std::string path ); + + virtual ModelIndex selectRowWithPath( const std::vector& pathTree ); virtual void setSelection( const ModelIndex& index, bool scrollToSelection = true, bool openModelIndexTree = true ); diff --git a/src/eepp/ui/uitreeview.cpp b/src/eepp/ui/uitreeview.cpp index cce81bad7..b5b7f49ab 100644 --- a/src/eepp/ui/uitreeview.cpp +++ b/src/eepp/ui/uitreeview.cpp @@ -779,19 +779,14 @@ ModelIndex UITreeView::findRowWithText( const std::string& text, const bool& cas return foundIndex; } -ModelIndex UITreeView::selectRowWithPath( std::string path ) { +ModelIndex UITreeView::selectRowWithPath( const std::vector& pathTree ) { const Model* model = getModel(); if ( !model || model->rowCount() == 0 ) return {}; - String::replaceAll( path, "\\", "/" ); - auto pathPart = String::split( path, "/" ); - if ( pathPart.empty() ) - return {}; - ModelIndex parentIndex = {}; - for ( size_t i = 0; i < pathPart.size(); i++ ) { + for ( size_t i = 0; i < pathTree.size(); i++ ) { ModelIndex foundIndex = {}; - const auto& part = pathPart[i]; + const auto& part = pathTree[i]; traverseTree( [&model, &foundIndex, &part, &parentIndex, @@ -813,7 +808,7 @@ ModelIndex UITreeView::selectRowWithPath( std::string path ) { parentIndex = foundIndex; - if ( i == pathPart.size() - 1 ) { + if ( i == pathTree.size() - 1 ) { setSelection( foundIndex ); return foundIndex; } @@ -821,6 +816,14 @@ ModelIndex UITreeView::selectRowWithPath( std::string path ) { return {}; } +ModelIndex UITreeView::selectRowWithPath( std::string path ) { + String::replaceAll( path, "\\", "/" ); + auto pathTree = String::split( path, "/" ); + if ( pathTree.empty() ) + return {}; + return selectRowWithPath( pathTree ); +} + void UITreeView::setSelection( const ModelIndex& index, bool scrollToSelection, bool openModelIndexTree ) { if ( !getModel() ) diff --git a/src/tools/ecode/plugins/lsp/lspclientplugin.cpp b/src/tools/ecode/plugins/lsp/lspclientplugin.cpp index 4e44947ad..85f23e69f 100644 --- a/src/tools/ecode/plugins/lsp/lspclientplugin.cpp +++ b/src/tools/ecode/plugins/lsp/lspclientplugin.cpp @@ -2006,7 +2006,7 @@ void LSPClientPlugin::updateCurrentSymbol( TextDocument& doc ) { if ( prevSymbols == mDocCurrentSymbols.end() || prevSymbols->second != symbolsInfo ) { mDocCurrentSymbols[uri] = std::move( symbolsInfo ); getManager()->getSplitter()->forEachEditor( [&uri]( UICodeEditor* editor ) { - if ( editor->getDocument().getURI() == uri ) + if ( editor->isVisible() && editor->getDocument().getURI() == uri ) editor->invalidateDraw(); } ); } @@ -2054,7 +2054,7 @@ void LSPClientPlugin::showDocumentSymbols( UICodeEditor* editor ) { std::vector path; for ( const auto& sym : docSymbols ) path.emplace_back( sym.name ); - tv->selectRowWithPath( String::join( path, '/' ) ); + tv->selectRowWithPath( path ); } } diff --git a/src/tools/ecode/plugins/lsp/lspdocumentclient.cpp b/src/tools/ecode/plugins/lsp/lspdocumentclient.cpp index 46ff1d31f..0159c77cc 100644 --- a/src/tools/ecode/plugins/lsp/lspdocumentclient.cpp +++ b/src/tools/ecode/plugins/lsp/lspdocumentclient.cpp @@ -321,7 +321,8 @@ void LSPDocumentClient::highlight() { } Clock clock; const auto& caps = mServer->getCapabilities().semanticTokenProvider; - Uint32 currentLine = 0; + Int64 firstLine = !data.empty() ? data[0] : -1; + Int64 currentLine = 0; Uint32 start = 0; std::unordered_map tokenizerLines; Int64 lastLine = 0; @@ -372,6 +373,16 @@ void LSPDocumentClient::highlight() { mDoc->getHighlighter()->mergeLine( tline.first, tline.second ); } + if ( firstLine != -1 && lastLine >= firstLine && mDoc ) { + getServer()->getManager()->getPlugin()->getManager()->getSplitter()->forEachEditor( + [this, firstLine, lastLine]( UICodeEditor* editor ) { + if ( editor->isVisible() && &editor->getDocument() == mDoc && + editor->getVisibleRange().intersectsLineRange( firstLine, lastLine ) ) { + editor->invalidateDraw(); + } + } ); + } + if ( !mServer->isSilent() ) { Log::debug( "LSPDocumentClient::highlight took: %.2f ms. Diff analysis took: %.2f ms. Updated "