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
fd9b2f20
Commit
fd9b2f20
authored
Jan 16, 2021
by
Kåre Särs
Browse files
Fix multi-line replace match ranges/marks
parent
8bc6db80
Changes
2
Hide whitespace changes
Inline
Side-by-side
addons/search/MatchModel.cpp
View file @
fd9b2f20
...
...
@@ -242,9 +242,6 @@ bool MatchModel::replaceMatch(KTextEditor::Document *doc, const QModelIndex &mat
int
newEndColumn
=
lastNL
==
-
1
?
matchItem
->
range
.
start
().
column
()
+
replaceText
.
length
()
:
replaceText
.
length
()
-
lastNL
-
1
;
matchItem
->
range
.
setEnd
(
KTextEditor
::
Cursor
{
newEndLine
,
newEndColumn
});
// Convert replace text back to "html"
replaceText
.
replace
(
QLatin1Char
(
'\n'
),
QStringLiteral
(
"
\\
n"
));
replaceText
.
replace
(
QLatin1Char
(
'\t'
),
QStringLiteral
(
"
\\
t"
));
matchItem
->
replaceText
=
replaceText
;
return
true
;
}
...
...
@@ -485,10 +482,10 @@ QString MatchModel::matchToHtmlString(const Match &match) const
}
pre
=
pre
.
toHtmlEscaped
();
QString
matchStr
=
match
.
matchStr
;
matchStr
.
replace
(
QLatin1Char
(
'\n'
),
QStringLiteral
(
"
\\
n"
));
matchStr
=
matchStr
.
toHtmlEscaped
();
QString
matchStr
=
match
.
matchStr
.
toHtmlEscaped
();;
QString
replaceStr
=
match
.
replaceText
.
toHtmlEscaped
();
if
(
!
replaceStr
.
isEmpty
())
{
matchStr
=
QLatin1String
(
"<i><s>"
)
+
matchStr
+
QLatin1String
(
"</s></i> "
);
}
...
...
@@ -500,6 +497,9 @@ QString MatchModel::matchToHtmlString(const Match &match) const
.
arg
(
m_replaceHighlightColor
.
name
(),
m_foregroundColor
.
name
(),
replaceStr
);
}
matchStr
.
replace
(
QLatin1Char
(
'\n'
),
QStringLiteral
(
"
\\
n"
));
matchStr
.
replace
(
QLatin1Char
(
'\t'
),
QStringLiteral
(
"
\\
t"
));
QString
post
=
match
.
postMatchStr
;
int
nlIndex
=
post
.
indexOf
(
QLatin1Char
(
'\n'
));
if
(
nlIndex
!=
-
1
)
{
...
...
@@ -602,6 +602,11 @@ QString MatchModel::matchToPlainText(const Match &match) const
}
QString
post
=
match
.
postMatchStr
;
matchStr
.
replace
(
QLatin1Char
(
'\n'
),
QStringLiteral
(
"
\\
n"
));
matchStr
.
replace
(
QLatin1Char
(
'\t'
),
QStringLiteral
(
"
\\
t"
));
replaceStr
.
replace
(
QLatin1Char
(
'\n'
),
QStringLiteral
(
"
\\
n"
));
replaceStr
.
replace
(
QLatin1Char
(
'\t'
),
QStringLiteral
(
"
\\
t"
));
// (line:col)[space][space] ...Line text pre [highlighted match] Line text post....
QString
displayText
=
QStringLiteral
(
"(%1:%2) "
)
.
arg
(
match
.
range
.
start
().
line
()
+
1
,
3
)
...
...
addons/search/plugin_search.cpp
View file @
fd9b2f20
...
...
@@ -798,7 +798,7 @@ void KatePluginSearchView::addMatchMark(KTextEditor::Document *doc, const QModel
}
}
else
{
if
(
doc
->
text
(
range
)
!=
itemIndex
.
data
(
MatchModel
::
ReplaceTextRole
).
toString
())
{
//
qDebug() << doc->text(range) << "Does not match" << item
->data(0, ReplaceMatches
::Replace
d
TextRole).toString();
//
/
qDebug() << doc->text(range) << "Does not match" << item
Index.data(MatchModel
::ReplaceTextRole).toString();
return
;
}
}
...
...
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