Changeset View
Changeset View
Standalone View
Standalone View
src/search/kateplaintextsearch.cpp
Show First 20 Lines • Show All 80 Lines • ▼ Show 20 Line(s) | 78 | for (int k = 0; k < needleLines.count(); k++) { | |||
---|---|---|---|---|---|
81 | const QString &hayLine = m_document->line(j + k); | 81 | const QString &hayLine = m_document->line(j + k); | ||
82 | 82 | | |||
83 | // position specific comparison (first, middle, last) | 83 | // position specific comparison (first, middle, last) | ||
84 | if (k == 0) { | 84 | if (k == 0) { | ||
85 | // first line | 85 | // first line | ||
86 | if (forMin == j && startCol < inputRange.start().column()) { | 86 | if (forMin == j && startCol < inputRange.start().column()) { | ||
87 | break; | 87 | break; | ||
88 | } | 88 | } | ||
89 | if (!hayLine.endsWith(needleLine, m_caseSensitivity)) { | 89 | | ||
90 | // NOTE: QString("")::endsWith("") is false in Qt, therefore we need the additional checks. | ||||
91 | const bool endsWith = hayLine.endsWith(needleLine, m_caseSensitivity) || (hayLine.isEmpty() && needleLine.isEmpty()); | ||||
92 | if (!endsWith) { | ||||
90 | break; | 93 | break; | ||
91 | } | 94 | } | ||
92 | } else if (k == needleLines.count() - 1) { | 95 | } else if (k == needleLines.count() - 1) { | ||
93 | // last line | 96 | // last line | ||
94 | const int maxRight = (j + k == inputRange.end().line()) ? inputRange.end().column() : hayLine.length(); | 97 | const int maxRight = (j + k == inputRange.end().line()) ? inputRange.end().column() : hayLine.length(); | ||
95 | 98 | | |||
96 | if (hayLine.startsWith(needleLine, m_caseSensitivity) && needleLine.length() <= maxRight) { | 99 | // NOTE: QString("")::startsWith("") is false in Qt, therefore we need the additional checks. | ||
100 | const bool startsWith = hayLine.startsWith(needleLine, m_caseSensitivity) || (hayLine.isEmpty() && needleLine.isEmpty()); | ||||
101 | if (startsWith && needleLine.length() <= maxRight) { | ||||
97 | return KTextEditor::Range(j, startCol, j + k, needleLine.length()); | 102 | return KTextEditor::Range(j, startCol, j + k, needleLine.length()); | ||
98 | } | 103 | } | ||
99 | } else { | 104 | } else { | ||
100 | // mid lines | 105 | // mid lines | ||
101 | if (hayLine.compare(needleLine, m_caseSensitivity) != 0) { | 106 | if (hayLine.compare(needleLine, m_caseSensitivity) != 0) { | ||
102 | break; | 107 | break; | ||
103 | } | 108 | } | ||
104 | } | 109 | } | ||
Show All 34 Lines |