Changeset View
Changeset View
Standalone View
Standalone View
src/vimode/completionreplayer.cpp
Show First 20 Lines • Show All 81 Lines • ▼ Show 20 Line(s) | 58 | { | |||
---|---|---|---|---|---|
82 | // Should we merge opening brackets? Yes, if completion is a function with arguments and after the cursor | 82 | // Should we merge opening brackets? Yes, if completion is a function with arguments and after the cursor | ||
83 | // there is (optional whitespace) followed by an open bracket. | 83 | // there is (optional whitespace) followed by an open bracket. | ||
84 | int offsetFinalCursorPosBy = 0; | 84 | int offsetFinalCursorPosBy = 0; | ||
85 | if (completion.completionType() == Completion::FunctionWithArgs) { | 85 | if (completion.completionType() == Completion::FunctionWithArgs) { | ||
86 | const int nextMergableBracketAfterCursorPos = findNextMergeableBracketPos(currentWord.end()); | 86 | const int nextMergableBracketAfterCursorPos = findNextMergeableBracketPos(currentWord.end()); | ||
87 | if (nextMergableBracketAfterCursorPos != -1) { | 87 | if (nextMergableBracketAfterCursorPos != -1) { | ||
88 | if (completionText.endsWith(QLatin1String("()"))) { | 88 | if (completionText.endsWith(QLatin1String("()"))) { | ||
89 | // Strip "()". | 89 | // Strip "()". | ||
90 | completionText = completionText.left(completionText.length() - 2); | 90 | completionText.chop(2); | ||
91 | } else if (completionText.endsWith(QLatin1String("();"))) { | 91 | } else if (completionText.endsWith(QLatin1String("();"))) { | ||
92 | // Strip "();". | 92 | // Strip "();". | ||
93 | completionText = completionText.left(completionText.length() - 3); | 93 | completionText.chop(3); | ||
94 | } | 94 | } | ||
95 | // Ensure cursor ends up after the merged open bracket. | 95 | // Ensure cursor ends up after the merged open bracket. | ||
96 | offsetFinalCursorPosBy = nextMergableBracketAfterCursorPos + 1; | 96 | offsetFinalCursorPosBy = nextMergableBracketAfterCursorPos + 1; | ||
97 | } else { | 97 | } else { | ||
98 | if (!completionText.endsWith(QLatin1String("()")) && !completionText.endsWith(QLatin1String("();"))) { | 98 | if (!completionText.endsWith(QLatin1String("()")) && !completionText.endsWith(QLatin1String("();"))) { | ||
99 | // Original completion merged with an opening bracket; we'll have to add our own brackets. | 99 | // Original completion merged with an opening bracket; we'll have to add our own brackets. | ||
100 | completionText.append(QLatin1String("()")); | 100 | completionText.append(QLatin1String("()")); | ||
101 | } | 101 | } | ||
▲ Show 20 Lines • Show All 54 Lines • Show Last 20 Lines |