Commit 8e330485 authored by Kevin Funk's avatar Kevin Funk
Browse files

Fix crash when activating code completion item

BUG: 391742
FIXED-IN: 5.2.2
parent 3f99e3de
......@@ -212,6 +212,10 @@ public:
}
if(m_declaration->isFunctionDeclaration()) {
const auto functionType = m_declaration->type<FunctionType>();
if (!functionType)
return;
auto doc = view->document();
// Function pointer?
......@@ -234,14 +238,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