Prevent endless loop when no matching brace is found

Would show up when typing ")," where the closing brace doesn't have a
matching opening brace, for example.

Done with Roberto Raggi.
This commit is contained in:
Thorbjørn Lindeijer
2009-04-09 11:00:40 +02:00
parent a0fa383235
commit cb75dd05ea

View File

@@ -265,9 +265,14 @@ int ExpressionUnderCursor::startOfFunctionCall(const QTextCursor &cursor)
break; break;
else if (tk.is(T_LPAREN)) else if (tk.is(T_LPAREN))
return startPosition + tk.position(); return startPosition + tk.position();
else if (tk.is(T_RPAREN)) else if (tk.is(T_RPAREN)) {
index = startOfMatchingBrace(tokens, index); int matchingBrace = startOfMatchingBrace(tokens, index);
else
if (matchingBrace == index) // If no matching brace found
return -1;
index = matchingBrace;
} else
--index; --index;
} }