Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Utilities
Kate
Commits
c30a6831
Commit
c30a6831
authored
Dec 28, 2020
by
Waqar Ahmed
Committed by
Christoph Cullmann
Dec 30, 2020
Browse files
Revert some changes from 1bad27
parent
f0f268f9
Changes
1
Hide whitespace changes
Inline
Side-by-side
addons/search/plugin_search.cpp
View file @
c30a6831
...
...
@@ -951,26 +951,29 @@ 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
;
if
(
!
m_curResults
||
(
sender
()
==
&
m_searchDiskFiles
&&
m_blockDiskMatchFound
))
{
return
;
}
QString
pre
=
lineContent
.
mid
(
0
,
startColumn
).
toHtmlEscaped
();
QString
match
=
lineContent
.
mid
(
startColumn
,
matchLen
);
int
preLen
=
contextLen
;
int
preStart
=
startColumn
-
preLen
;
if
(
preStart
<
0
)
{
preLen
+=
preStart
;
preStart
=
0
;
}
QString
pre
;
if
(
preLen
==
contextLen
)
{
pre
=
QStringLiteral
(
"..."
);
}
pre
+=
lineContent
.
mid
(
preStart
,
preLen
).
toHtmlEscaped
();
QString
match
=
lineContent
.
mid
(
startColumn
,
matchLen
).
toHtmlEscaped
();
match
.
replace
(
QLatin1Char
(
'\n'
),
QStringLiteral
(
"
\\
n"
));
QString
post
=
lineContent
.
mid
(
startColumn
+
matchLen
).
toHtmlEscaped
();
// a string too long can lead to rendering issues and slow downs
if
(
pre
.
length
()
+
post
.
length
()
>
300
)
{
// which is greater in length? resize that
if
(
post
.
length
()
>
150
)
{
post
.
truncate
(
97
);
post
.
append
(
QStringLiteral
(
"..."
));
}
else
if
(
pre
.
length
()
>
150
)
{
pre
.
truncate
(
97
);
pre
.
append
(
QStringLiteral
(
"..."
));
}
QString
post
=
lineContent
.
mid
(
startColumn
+
matchLen
,
contextLen
);
if
(
post
.
size
()
>=
contextLen
)
{
post
+=
QStringLiteral
(
"..."
);
}
post
=
post
.
toHtmlEscaped
();
QString
style
=
QStringLiteral
(
"<span style=
\"
background-color:"
)
+
m_searchBackgroundColor
+
QStringLiteral
(
";
\"
>"
);
pre
.
append
(
style
+
match
+
QStringLiteral
(
"</span>"
)
+
post
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment