Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 43c1faac authored by Sven Brauch's avatar Sven Brauch

cpp code completion: do not add () when function call is prefixed by &

useful for typing signals and slots, e.g.
	connect(this, &QDialog::acc|
will no longer add the parentheses when completing "accepted".
The "take address of the return value of function call" case is possible of
course, but close to never what you want to do.
parent 002fbc58
......@@ -204,7 +204,20 @@ public:
if(m_declaration->isFunctionDeclaration()) {
auto doc = view->document();
if (doc->characterAt(word.end()) != QLatin1Char('(')) {
// Function pointer?
bool funcptr = false;
const auto line = doc->line(word.start().line());
auto pos = word.end().column() - 1;
while ( pos > 0 && (line.at(pos).isLetterOrNumber() || line.at(pos) == QLatin1Char(':')) ) {
pos--;
if ( line.at(pos) == QLatin1Char('&') ) {
funcptr = true;
break;
}
}
if ( !funcptr && doc->characterAt(word.end()) != QLatin1Char('(') ) {
repl += QLatin1String("()");
}
view->document()->replaceText(word, repl);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment