Commit 0b55713e authored by Waqar Ahmed's avatar Waqar Ahmed Committed by Christoph Cullmann
Browse files

Revert to previous context length

parent c30a6831
......@@ -951,7 +951,7 @@ void KatePluginSearchView::addMatchMark(KTextEditor::Document *doc, QTreeWidgetI
void KatePluginSearchView::matchFound(const QString &url, const QString &fName, const QString &lineContent, int matchLen, int startLine, int startColumn, int endLine, int endColumn)
{
static constexpr int contextLen = 140;
static constexpr int contextLen = 70;
if (!m_curResults || (sender() == &m_searchDiskFiles && m_blockDiskMatchFound)) {
return;
......@@ -975,11 +975,12 @@ void KatePluginSearchView::matchFound(const QString &url, const QString &fName,
}
post = post.toHtmlEscaped();
QString style = QStringLiteral("<span style=\"background-color:") + m_searchBackgroundColor + QStringLiteral(";\">");
pre.append(style + match + QStringLiteral("</span>") + post);
QString displayText = QStringLiteral("(<span style=\"color:%3;\">%1:%2</span>) &nbsp;").arg(startLine + 1).arg(startColumn + 1).arg(m_lineNumberColor);
QString matchHighlighted = QStringLiteral("<span style=\"background-color:%1; color:%2;\">%3</span>").arg(m_searchBackgroundColor).arg(m_foregroundColor).arg(match);
pre.append(matchHighlighted + post);
displayText.append(pre);
QStringList txt{pre};
TreeWidgetItem *item = new TreeWidgetItem(static_cast<TreeWidgetItem*>(nullptr), txt);
TreeWidgetItem *item = new TreeWidgetItem(static_cast<TreeWidgetItem*>(nullptr), QStringList{displayText});
item->setData(0, ReplaceMatches::FileUrlRole, url);
item->setData(0, Qt::ToolTipRole, url);
......@@ -1113,11 +1114,20 @@ void KatePluginSearchView::startSearch()
return;
}
// search color to use in search results
KTextEditor::ConfigInterface *ciface = qobject_cast<KTextEditor::ConfigInterface *>(m_mainWindow->activeView());
if (ciface) {
m_searchBackgroundColor = ciface->configValue(QStringLiteral("search-highlight-color")).value<QColor>().name();
qobject_cast<SPHtmlDelegate*>(m_curResults->tree->itemDelegate())->setDisplayFont(ciface->configValue(QStringLiteral("font")).value<QFont>());
/**
* update the search widget colors. This is done on start of every
* search so that if the user changes the theme, he can see the new colors
* on the next search
*/
{
KTextEditor::ConfigInterface *ciface = qobject_cast<KTextEditor::ConfigInterface *>(m_mainWindow->activeView());
if (ciface) {
// save for later reuse when the search tree starts getting populated
m_searchBackgroundColor = ciface->configValue(QStringLiteral("search-highlight-color")).value<QColor>().name();
m_lineNumberColor = ciface->configValue(QStringLiteral("line-number-color")).value<QColor>().name();
m_foregroundColor = m_mainWindow->activeView()->defaultStyleAttribute(KTextEditor::dsNormal)->foreground().color().name();
qobject_cast<SPHtmlDelegate*>(m_curResults->tree->itemDelegate())->setDisplayFont(ciface->configValue(QStringLiteral("font")).value<QFont>());
}
}
m_curResults->regExp = reg;
......
......@@ -207,6 +207,8 @@ private:
QTimer m_updateSumaryTimer;
QPointer<KTextEditor::Message> m_infoMessage;
QString m_searchBackgroundColor;
QString m_foregroundColor;
QString m_lineNumberColor;
/**
* current project plugin view, if any
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment