Changeset View
Changeset View
Standalone View
Standalone View
src/search/kateplaintextsearch.cpp
Show First 20 Lines • Show All 51 Lines • ▼ Show 20 Line(s) | |||||
52 | 52 | | |||
53 | KTextEditor::Range KatePlainTextSearch::search(const QString &text, const KTextEditor::Range &inputRange, bool backwards) | 53 | KTextEditor::Range KatePlainTextSearch::search(const QString &text, const KTextEditor::Range &inputRange, bool backwards) | ||
54 | { | 54 | { | ||
55 | // abuse regex for whole word plaintext search | 55 | // abuse regex for whole word plaintext search | ||
56 | if (m_wholeWords) { | 56 | if (m_wholeWords) { | ||
57 | // escape dot and friends | 57 | // escape dot and friends | ||
58 | const QString workPattern = QStringLiteral("\\b%1\\b").arg(QRegularExpression::escape(text)); | 58 | const QString workPattern = QStringLiteral("\\b%1\\b").arg(QRegularExpression::escape(text)); | ||
59 | 59 | | |||
60 | return KateRegExpSearch(m_document, m_caseSensitivity).search(workPattern, inputRange, backwards).at(0); | 60 | QRegularExpression::PatternOptions options; | ||
61 | options |= m_caseSensitivity == Qt::CaseInsensitive ? QRegularExpression::CaseInsensitiveOption : QRegularExpression::NoPatternOption; | ||||
62 | | ||||
63 | return KateRegExpSearch(m_document).search(workPattern, inputRange, backwards, options).at(0); | ||||
61 | } | 64 | } | ||
62 | 65 | | |||
63 | if (text.isEmpty() || !inputRange.isValid() || (inputRange.start() == inputRange.end())) { | 66 | if (text.isEmpty() || !inputRange.isValid() || (inputRange.start() == inputRange.end())) { | ||
64 | return KTextEditor::Range::invalid(); | 67 | return KTextEditor::Range::invalid(); | ||
65 | } | 68 | } | ||
66 | 69 | | |||
67 | // split multi-line needle into single lines | 70 | // split multi-line needle into single lines | ||
68 | const auto needleLines = text.splitRef(QLatin1Char('\n')); | 71 | const auto needleLines = text.splitRef(QLatin1Char('\n')); | ||
▲ Show 20 Lines • Show All 75 Lines • Show Last 20 Lines |