Changeset View
Changeset View
Standalone View
Standalone View
src/view/kateview.cpp
Show First 20 Lines • Show All 80 Lines • ▼ Show 20 Line(s) | |||||
81 | #include <QFont> | 81 | #include <QFont> | ||
82 | #include <QKeyEvent> | 82 | #include <QKeyEvent> | ||
83 | #include <QApplication> | 83 | #include <QApplication> | ||
84 | #include <QLayout> | 84 | #include <QLayout> | ||
85 | #include <QPainter> | 85 | #include <QPainter> | ||
86 | #include <QClipboard> | 86 | #include <QClipboard> | ||
87 | #include <QFileDialog> | 87 | #include <QFileDialog> | ||
88 | #include <QToolTip> | 88 | #include <QToolTip> | ||
89 | #include <QRegularExpression> | ||||
89 | 90 | | |||
90 | //#define VIEW_RANGE_DEBUG | 91 | //#define VIEW_RANGE_DEBUG | ||
91 | 92 | | |||
92 | //END includes | 93 | //END includes | ||
93 | 94 | | |||
94 | namespace { | 95 | namespace { | ||
95 | 96 | | |||
96 | bool hasCommentInFirstLine(KTextEditor::DocumentPrivate* doc) | 97 | bool hasCommentInFirstLine(KTextEditor::DocumentPrivate* doc) | ||
▲ Show 20 Lines • Show All 3698 Lines • ▼ Show 20 Line(s) | 3778 | { | |||
3795 | /** | 3796 | /** | ||
3796 | * only add word boundary if we can find the text then | 3797 | * only add word boundary if we can find the text then | ||
3797 | * fixes $lala hl | 3798 | * fixes $lala hl | ||
3798 | */ | 3799 | */ | ||
3799 | QString regex = QRegExp::escape (m_currentTextForHighlights); | 3800 | QString regex = QRegExp::escape (m_currentTextForHighlights); | ||
3800 | if (QRegExp (QStringLiteral("\\b%1").arg(regex)).indexIn (QStringLiteral(" %1 ").arg(m_currentTextForHighlights)) != -1) | 3801 | if (QRegExp (QStringLiteral("\\b%1").arg(regex)).indexIn (QStringLiteral(" %1 ").arg(m_currentTextForHighlights)) != -1) | ||
3801 | regex = QStringLiteral("\\b%1").arg(regex); | 3802 | regex = QStringLiteral("\\b%1").arg(regex); | ||
3802 | if (QRegExp (QStringLiteral("%1\\b").arg(regex)).indexIn (QStringLiteral(" %1 ").arg(m_currentTextForHighlights)) != -1) | 3803 | if (QRegExp (QStringLiteral("%1\\b").arg(regex)).indexIn (QStringLiteral(" %1 ").arg(m_currentTextForHighlights)) != -1) | ||
3803 | regex = QStringLiteral("%1\\b").arg(regex); | 3804 | regex = QStringLiteral("%1\\b").arg(regex); | ||
mwolff: what was that old code trying to do? did you understand it? | |||||
Now that's a good point: I don't completely. dhaumann: Now that's a good point: I don't completely.
It appends a leading and trailing space, and the… | |||||
I think the old code tried to ensure we only add word-boundary if we still can find the string then. e.g. if the string that you highlight contains spaces or stuff like that at the borders, you don't add \b. cullmann: I think the old code tried to ensure we only add word-boundary if we still can find the string… | |||||
dhaumann: This part is still not done. Besides that, this patch should be fine. | |||||
3804 | | ||||
3805 | QVector<KTextEditor::Range> matches; | 3805 | QVector<KTextEditor::Range> matches; | ||
3806 | do { | 3806 | do { | ||
3807 | searchRange.setRange(start, visibleRange().end()); | 3807 | searchRange.setRange(start, visibleRange().end()); | ||
3808 | 3808 | | |||
3809 | matches = doc()->searchText(searchRange, regex, KTextEditor::Regex); | 3809 | matches = doc()->searchText(searchRange, regex, KTextEditor::Regex); | ||
3810 | 3810 | | |||
3811 | if (matches.first().isValid()) { | 3811 | if (matches.first().isValid()) { | ||
3812 | KTextEditor::MovingRange* mr = doc()->newMovingRange(matches.first()); | 3812 | KTextEditor::MovingRange* mr = doc()->newMovingRange(matches.first()); | ||
▲ Show 20 Lines • Show All 148 Lines • Show Last 20 Lines |
what was that old code trying to do? did you understand it?