diff --git a/src/plugins/coreplugin/locator/commandlocator.cpp b/src/plugins/coreplugin/locator/commandlocator.cpp index 9c644f4f998..387cae9fef6 100644 --- a/src/plugins/coreplugin/locator/commandlocator.cpp +++ b/src/plugins/coreplugin/locator/commandlocator.cpp @@ -17,7 +17,7 @@ namespace Core { struct CommandLocatorPrivate { QList commands; - QList> commandsData; + QList> commandsData; }; /*! @@ -61,7 +61,7 @@ void CommandLocator::prepareSearch(const QString &entry) continue; QAction *action = command->action(); if (action && action->isEnabled()) - d->commandsData.append({action, action->text()}); + d->commandsData.append({i, action->text()}); } } @@ -77,17 +77,8 @@ QList CommandLocator::matchesFor(QFutureInterface= 0) { - QAction *action = pair.first; - LocatorFilterEntry filterEntry; - filterEntry.displayName = text; - filterEntry.acceptor = [action] { - // avoid nested stack trace and blocking locator by delayed triggering - QMetaObject::invokeMethod(action, [action] { - if (action->isEnabled()) - action->trigger(); - }, Qt::QueuedConnection); - return AcceptResult(); - }; + LocatorFilterEntry filterEntry(this, text); + filterEntry.internalData = QVariant(pair.first); filterEntry.highlightInfo = {index, int(entry.length())}; if (index == 0) @@ -100,4 +91,21 @@ QList CommandLocator::matchesFor(QFutureInterface= 0 && index < d->commands.size(), return); + QAction *action = d->commands.at(index)->action(); + // avoid nested stack trace and blocking locator by delayed triggering + QMetaObject::invokeMethod(action, [action] { + if (action->isEnabled()) + action->trigger(); + }, Qt::QueuedConnection); +} + } // namespace Core diff --git a/src/plugins/coreplugin/locator/commandlocator.h b/src/plugins/coreplugin/locator/commandlocator.h index e47fbde5c41..8199661bed6 100644 --- a/src/plugins/coreplugin/locator/commandlocator.h +++ b/src/plugins/coreplugin/locator/commandlocator.h @@ -26,6 +26,9 @@ public: void prepareSearch(const QString &entry) override; QList matchesFor(QFutureInterface &future, const QString &entry) override; + void accept(const LocatorFilterEntry &selection, + QString *newText, int *selectionStart, int *selectionLength) const override; + private: CommandLocatorPrivate *d = nullptr; };