Skip to content

Commit

Permalink
fix: [search] The background color position is incorrect
Browse files Browse the repository at this point in the history
as title

Log: fix issue
  • Loading branch information
Kakueeen authored and deepin-mozart committed Dec 4, 2024
1 parent 2091f3a commit 5430fa6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/plugins/find/gui/searchresultitemdelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<QTextLayout::FormatRange> 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()) {
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")

0 comments on commit 5430fa6

Please sign in to comment.