Invalidate draw when editor updates its highlight.

Minor improvement on breadcrumb draw invalidation.
This commit is contained in:
Martín Lucas Golini
2024-08-29 11:41:07 -03:00
parent 2334ec078c
commit a10f587545
4 changed files with 29 additions and 13 deletions

View File

@@ -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<std::string> path;
for ( const auto& sym : docSymbols )
path.emplace_back( sym.name );
tv->selectRowWithPath( String::join( path, '/' ) );
tv->selectRowWithPath( path );
}
}

View File

@@ -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<size_t, TokenizedLine> 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 "