| 324 | } |
| 325 | |
| 326 | void ExternalScriptPlugin::executeScriptFromContextMenu() const |
| 327 | { |
| 328 | auto* action = qobject_cast<QAction*>(sender()); |
| 329 | Q_ASSERT(action); |
| 330 | |
| 331 | auto* item = action->data().value<ExternalScriptItem*>(); |
| 332 | Q_ASSERT(item); |
| 333 | |
| 334 | for (const QUrl& url : m_urls) { |
| 335 | // An empty URL here probably means that the user triggered an external script action from an untitled |
| 336 | // document's context menu. In this case EditorContext::url() returns an untitled KTextEditor::Document's |
| 337 | // URL, which is empty. An empty QUrl is relative, so attempting to open an empty URL makes the assertion |
| 338 | // !inputUrl.isRelative() in DocumentControllerPrivate::openDocumentInternal() fail. |
| 339 | // Therefore, do not attempt to open a document for an empty URL. In the discussed scenario the untitled |
| 340 | // document is already open and active. Thus the triggered external script action can work correctly. |
| 341 | if (!url.isEmpty()) { |
| 342 | KDevelop::ICore::self()->documentController()->openDocument(url); |
| 343 | } |
| 344 | execute(item, url); |
| 345 | } |
| 346 | } |
| 347 | |
| 348 | void ExternalScriptPlugin::rowsInserted(const QModelIndex& /*parent*/, int start, int end) |
| 349 | { |
nothing calls this directly
no test coverage detected