diff -r c2e0db52ea07 -r eae8b3bce545 src/toolsets/basictoolset.cpp --- a/src/toolsets/basictoolset.cpp Sun Mar 05 13:33:37 2017 +0200 +++ b/src/toolsets/basictoolset.cpp Sun Mar 05 16:47:52 2017 +0200 @@ -98,19 +98,16 @@ { // Get the index of the subfile so we know where to insert the // inlined contents. - int idx = reference->lineNumber(); + int position = reference->lineNumber(); - if (idx != -1) + if (position != -1) { Model inlined {m_documents}; reference->inlineContents(inlined, deep, false); - - // Merge in the inlined objects - for (LDObject* inlinedObject : inlined.objects()) + currentDocument()->merge(inlined, position, nullptr, [&](LDObject* object, int) { - currentDocument()->insertObject (idx++, inlinedObject); - currentDocument()->addToSelection(inlinedObject); - } + currentDocument()->addToSelection(object); + }); // Delete the subfile now as it's been inlined. currentDocument()->remove(reference); @@ -299,4 +296,4 @@ void BasicToolset::modeLinePath() { m_window->renderer()->setEditMode (EditModeType::LinePath); -} \ No newline at end of file +}