Changeset View
Changeset View
Standalone View
Standalone View
src/vimode/emulatedcommandbar/searchmode.cpp
Show First 20 Lines • Show All 145 Lines • ▼ Show 20 Line(s) | 143 | if (matchingClosedCurlyBracketPositions.isEmpty()) { | |||
---|---|---|---|---|---|
146 | qtRegexPattern = toggledEscaped(qtRegexPattern, QLatin1Char('}')); | 146 | qtRegexPattern = toggledEscaped(qtRegexPattern, QLatin1Char('}')); | ||
147 | } else { | 147 | } else { | ||
148 | // Ensure that every chunk of qtRegexPattern that does *not* contain a curly closing bracket | 148 | // Ensure that every chunk of qtRegexPattern that does *not* contain a curly closing bracket | ||
149 | // that is matched have their { and } escaping toggled. | 149 | // that is matched have their { and } escaping toggled. | ||
150 | QString qtRegexPatternNonMatchingCurliesToggled; | 150 | QString qtRegexPatternNonMatchingCurliesToggled; | ||
151 | int previousNonMatchingClosedCurlyPos = 0; // i.e. the position of the last character which is either | 151 | int previousNonMatchingClosedCurlyPos = 0; // i.e. the position of the last character which is either | ||
152 | // not a curly closing bracket, or is a curly closing bracket | 152 | // not a curly closing bracket, or is a curly closing bracket | ||
153 | // that is not matched. | 153 | // that is not matched. | ||
154 | foreach (int matchingClosedCurlyPos, matchingClosedCurlyBracketPositions) { | 154 | for (int matchingClosedCurlyPos : qAsConst(matchingClosedCurlyBracketPositions)) { | ||
155 | QString chunkExcludingMatchingCurlyClosed = qtRegexPattern.mid(previousNonMatchingClosedCurlyPos, matchingClosedCurlyPos - previousNonMatchingClosedCurlyPos); | 155 | QString chunkExcludingMatchingCurlyClosed = qtRegexPattern.mid(previousNonMatchingClosedCurlyPos, matchingClosedCurlyPos - previousNonMatchingClosedCurlyPos); | ||
156 | chunkExcludingMatchingCurlyClosed = toggledEscaped(chunkExcludingMatchingCurlyClosed, QLatin1Char('{')); | 156 | chunkExcludingMatchingCurlyClosed = toggledEscaped(chunkExcludingMatchingCurlyClosed, QLatin1Char('{')); | ||
157 | chunkExcludingMatchingCurlyClosed = toggledEscaped(chunkExcludingMatchingCurlyClosed, QLatin1Char('}')); | 157 | chunkExcludingMatchingCurlyClosed = toggledEscaped(chunkExcludingMatchingCurlyClosed, QLatin1Char('}')); | ||
158 | qtRegexPatternNonMatchingCurliesToggled += chunkExcludingMatchingCurlyClosed + | 158 | qtRegexPatternNonMatchingCurliesToggled += chunkExcludingMatchingCurlyClosed + | ||
159 | qtRegexPattern[matchingClosedCurlyPos]; | 159 | qtRegexPattern[matchingClosedCurlyPos]; | ||
160 | previousNonMatchingClosedCurlyPos = matchingClosedCurlyPos + 1; | 160 | previousNonMatchingClosedCurlyPos = matchingClosedCurlyPos + 1; | ||
161 | } | 161 | } | ||
162 | QString chunkAfterLastMatchingClosedCurly = qtRegexPattern.mid(matchingClosedCurlyBracketPositions.last() + 1); | 162 | QString chunkAfterLastMatchingClosedCurly = qtRegexPattern.mid(matchingClosedCurlyBracketPositions.last() + 1); | ||
Show All 29 Lines | 189 | if (matchingSquareBracketPositions.isEmpty()) { | |||
192 | qtRegexPattern = ensuredCharEscaped(qtRegexPattern, QLatin1Char(']')); | 192 | qtRegexPattern = ensuredCharEscaped(qtRegexPattern, QLatin1Char(']')); | ||
193 | } else { | 193 | } else { | ||
194 | // Ensure that every chunk of qtRegexPattern that does *not* contain one of the matching pairs of | 194 | // Ensure that every chunk of qtRegexPattern that does *not* contain one of the matching pairs of | ||
195 | // square brackets have their square brackets escaped. | 195 | // square brackets have their square brackets escaped. | ||
196 | QString qtRegexPatternNonMatchingSquaresMadeLiteral; | 196 | QString qtRegexPatternNonMatchingSquaresMadeLiteral; | ||
197 | int previousNonMatchingSquareBracketPos = 0; // i.e. the position of the last character which is | 197 | int previousNonMatchingSquareBracketPos = 0; // i.e. the position of the last character which is | ||
198 | // either not a square bracket, or is a square bracket but | 198 | // either not a square bracket, or is a square bracket but | ||
199 | // which is not matched. | 199 | // which is not matched. | ||
200 | foreach (int matchingSquareBracketPos, matchingSquareBracketPositions) { | 200 | for (int matchingSquareBracketPos : qAsConst(matchingSquareBracketPositions)) { | ||
201 | QString chunkExcludingMatchingSquareBrackets = qtRegexPattern.mid(previousNonMatchingSquareBracketPos, matchingSquareBracketPos - previousNonMatchingSquareBracketPos); | 201 | QString chunkExcludingMatchingSquareBrackets = qtRegexPattern.mid(previousNonMatchingSquareBracketPos, matchingSquareBracketPos - previousNonMatchingSquareBracketPos); | ||
202 | chunkExcludingMatchingSquareBrackets = ensuredCharEscaped(chunkExcludingMatchingSquareBrackets, QLatin1Char('[')); | 202 | chunkExcludingMatchingSquareBrackets = ensuredCharEscaped(chunkExcludingMatchingSquareBrackets, QLatin1Char('[')); | ||
203 | chunkExcludingMatchingSquareBrackets = ensuredCharEscaped(chunkExcludingMatchingSquareBrackets, QLatin1Char(']')); | 203 | chunkExcludingMatchingSquareBrackets = ensuredCharEscaped(chunkExcludingMatchingSquareBrackets, QLatin1Char(']')); | ||
204 | qtRegexPatternNonMatchingSquaresMadeLiteral += chunkExcludingMatchingSquareBrackets + qtRegexPattern[matchingSquareBracketPos]; | 204 | qtRegexPatternNonMatchingSquaresMadeLiteral += chunkExcludingMatchingSquareBrackets + qtRegexPattern[matchingSquareBracketPos]; | ||
205 | previousNonMatchingSquareBracketPos = matchingSquareBracketPos + 1; | 205 | previousNonMatchingSquareBracketPos = matchingSquareBracketPos + 1; | ||
206 | } | 206 | } | ||
207 | QString chunkAfterLastMatchingSquareBracket = qtRegexPattern.mid(matchingSquareBracketPositions.last() + 1); | 207 | QString chunkAfterLastMatchingSquareBracket = qtRegexPattern.mid(matchingSquareBracketPositions.last() + 1); | ||
208 | chunkAfterLastMatchingSquareBracket = ensuredCharEscaped(chunkAfterLastMatchingSquareBracket, QLatin1Char('[')); | 208 | chunkAfterLastMatchingSquareBracket = ensuredCharEscaped(chunkAfterLastMatchingSquareBracket, QLatin1Char('[')); | ||
▲ Show 20 Lines • Show All 178 Lines • Show Last 20 Lines |