From 5e8199dd6d3e8a88b95c584f79f7ad3e6b1ff372 Mon Sep 17 00:00:00 2001 From: Liu Zhangjian Date: Tue, 3 Dec 2024 13:23:49 +0800 Subject: [PATCH] fix: [search] The background color position is incorrect as title Log: fix issue --- src/plugins/find/gui/searchresultitemdelegate.cpp | 12 +++++++++++- src/scripts/CMakeLists.txt | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/plugins/find/gui/searchresultitemdelegate.cpp b/src/plugins/find/gui/searchresultitemdelegate.cpp index e53a0708b..7fd6d1d6c 100644 --- a/src/plugins/find/gui/searchresultitemdelegate.cpp +++ b/src/plugins/find/gui/searchresultitemdelegate.cpp @@ -402,6 +402,7 @@ void SearchResultItemDelegate::drawDisplay(QPainter *painter, const QStyleOption painter->setPen(option.palette.color(QPalette::Normal, QPalette::Text)); } + // Remove leading spaces QString displayText = text.trimmed(); if (displayText.isEmpty()) return; @@ -420,7 +421,16 @@ void SearchResultItemDelegate::drawDisplay(QPainter *painter, const QStyleOption textLayout.setTextOption(textOption); textLayout.setFont(option.font); textLayout.setText(displayText); - textLayout.setFormats(formatList.toVector()); + + // Adjust offsets in formatList + int offset = text.indexOf(displayText); + QList adjustedFormats = formatList; + if (offset != 0) { + for (auto &format : adjustedFormats) { + format.start -= offset; + } + } + textLayout.setFormats(adjustedFormats.toVector()); QSizeF textLayoutSize = doTextLayout(&textLayout, textRect.width()); if (textRect.width() < textLayoutSize.width()) { diff --git a/src/scripts/CMakeLists.txt b/src/scripts/CMakeLists.txt index 76bcc61ad..4aea43722 100644 --- a/src/scripts/CMakeLists.txt +++ b/src/scripts/CMakeLists.txt @@ -25,5 +25,5 @@ install(DIRECTORY rag/ install(DIRECTORY compiledb/ DESTINATION "${LIBRARY_INSTALL_PREFIX}/scripts/compiledb") -install(DIRECTORY compiledb/ +install(DIRECTORY toolchain/ DESTINATION "${LIBRARY_INSTALL_PREFIX}/scripts/toolchain")