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 9bb84876 authored by Kevin Funk's avatar Kevin Funk Committed by Friedrich W. H. Kossebau

Fix crash when activating code completion item

Reapplying to master, somehow got lost in merge commit
49e2e165

(cherry picked from commit 8e330485)
parent 17547955
......@@ -212,6 +212,13 @@ public:
}
if(m_declaration->isFunctionDeclaration()) {
const auto functionType = m_declaration->type<FunctionType>();
// protect against buggy code that created the m_declaration,
// to mark it as a function but not assign a function type
if (!functionType)
return;
auto doc = view->document();
// Function pointer?
......@@ -234,14 +241,13 @@ public:
didAddParentheses = true;
}
view->document()->replaceText(word, repl);
auto f = m_declaration->type<FunctionType>();
if (f && f->indexedArgumentsSize() && didAddParentheses) {
if (functionType->indexedArgumentsSize() && didAddParentheses) {
view->setCursorPosition(word.start() + KTextEditor::Cursor(0, repl.size() - 1));
}
auto returnTypeIntegral = f->returnType().cast<IntegralType>();
auto returnTypeIntegral = functionType->returnType().cast<IntegralType>();
if ( restEmpty && !funcptr && returnTypeIntegral && returnTypeIntegral->dataType() == IntegralType::TypeVoid ) {
// function returns void and rest of line is empty -- nothing can be done with the result
if ( f && f->indexedArgumentsSize() ) {
if (functionType->indexedArgumentsSize() ) {
// we placed the cursor inside the ()
view->document()->insertText(view->cursorPosition() + KTextEditor::Cursor(0, 1), QStringLiteral(";"));
}
......
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