Changeset View
Changeset View
Standalone View
Standalone View
src/vimode/modes/modebase.cpp
Show First 20 Lines • Show All 51 Lines • ▼ Show 20 Line(s) | |||||
52 | // because they will simply be called again from the last found position. | 52 | // because they will simply be called again from the last found position. | ||
53 | // They should take the count as a parameter and collect the positions in a QList, then return | 53 | // They should take the count as a parameter and collect the positions in a QList, then return | ||
54 | // element (count - 1) | 54 | // element (count - 1) | ||
55 | 55 | | |||
56 | //////////////////////////////////////////////////////////////////////////////// | 56 | //////////////////////////////////////////////////////////////////////////////// | ||
57 | // HELPER METHODS | 57 | // HELPER METHODS | ||
58 | //////////////////////////////////////////////////////////////////////////////// | 58 | //////////////////////////////////////////////////////////////////////////////// | ||
59 | 59 | | |||
60 | void ModeBase::yankToClipBoard(QChar chosen_register, QString text) | 60 | void ModeBase::yankToClipBoard(QChar chosen_register, const QString &text) | ||
61 | { | 61 | { | ||
62 | // only yank to the clipboard if no register was specified, | 62 | // only yank to the clipboard if no register was specified, | ||
63 | // textlength > 1 and there is something else then whitespace | 63 | // textlength > 1 and there is something else then whitespace | ||
64 | if ((chosen_register == QLatin1Char('0') || chosen_register == QLatin1Char('-')) && text.length() > 1 && !text.trimmed().isEmpty()) { | 64 | if ((chosen_register == QLatin1Char('0') || chosen_register == QLatin1Char('-')) && text.length() > 1 && !text.trimmed().isEmpty()) { | ||
65 | KTextEditor::EditorPrivate::self()->copyToClipboard(text); | 65 | KTextEditor::EditorPrivate::self()->copyToClipboard(text); | ||
66 | } | 66 | } | ||
67 | } | 67 | } | ||
68 | 68 | | |||
▲ Show 20 Lines • Show All 254 Lines • ▼ Show 20 Line(s) | 288 | { | |||
323 | 323 | | |||
324 | return KTextEditor::Cursor(l, c); | 324 | return KTextEditor::Cursor(l, c); | ||
325 | } | 325 | } | ||
326 | 326 | | |||
327 | KTextEditor::Cursor ModeBase::findPrevWORDEnd(int fromLine, int fromColumn, bool onlyCurrentLine) const | 327 | KTextEditor::Cursor ModeBase::findPrevWORDEnd(int fromLine, int fromColumn, bool onlyCurrentLine) const | ||
328 | { | 328 | { | ||
329 | QString line = getLine(fromLine); | 329 | QString line = getLine(fromLine); | ||
330 | 330 | | |||
331 | QRegExp endOfWORDPattern(QLatin1String("\\S\\s|\\S$|^$")); | 331 | const QRegExp endOfWORDPattern(QLatin1String("\\S\\s|\\S$|^$")); | ||
332 | | ||||
333 | QRegExp endOfWORD(endOfWORDPattern); | | |||
aacid: This is wrong, QRegExp is broken and lastIndexIn modifies the object even if the function is… | |||||
Hmm, given that is a local var on the stack, I don't see an issue with this. cullmann: Hmm, given that is a local var on the stack, I don't see an issue with this.
This would only be… | |||||
right is a local var ^_^ i got confused by a similar-ish patch in qtbase where the qregexp was passed in. aacid: right is a local var ^_^ i got confused by a similar-ish patch in qtbase where the qregexp was… | |||||
334 | 332 | | |||
335 | int l = fromLine; | 333 | int l = fromLine; | ||
336 | int c = fromColumn; | 334 | int c = fromColumn; | ||
337 | 335 | | |||
338 | bool found = false; | 336 | bool found = false; | ||
339 | 337 | | |||
340 | while (!found) { | 338 | while (!found) { | ||
341 | int c1 = endOfWORD.lastIndexIn(line, c - 1); | 339 | int c1 = endOfWORDPattern.lastIndexIn(line, c - 1); | ||
342 | 340 | | |||
343 | if (c1 != -1 && c - 1 != -1) { | 341 | if (c1 != -1 && c - 1 != -1) { | ||
344 | found = true; | 342 | found = true; | ||
345 | c = c1; | 343 | c = c1; | ||
346 | } else { | 344 | } else { | ||
347 | if (onlyCurrentLine) { | 345 | if (onlyCurrentLine) { | ||
348 | return KTextEditor::Cursor::invalid(); | 346 | return KTextEditor::Cursor::invalid(); | ||
349 | } else if (l > 0) { | 347 | } else if (l > 0) { | ||
▲ Show 20 Lines • Show All 999 Lines • Show Last 20 Lines |
This is wrong, QRegExp is broken and lastIndexIn modifies the object even if the function is marked as const