forked from qt-creator/qt-creator
FakeVim: Simplify completion support setup
That's the "word based" completion triggered by Ctrl-N. Change-Id: Ib35d7e6d2fa0fc144cd92d09d22c279d50aa2fdc Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -347,8 +347,6 @@ using UserCommandMap = QMap<int, QString>;
|
|||||||
//
|
//
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
class FakeVimPluginRunData;
|
|
||||||
|
|
||||||
class FakeVimPluginPrivate : public QObject
|
class FakeVimPluginPrivate : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -428,7 +426,6 @@ public:
|
|||||||
UserCommandMap m_defaultUserCommandMap;
|
UserCommandMap m_defaultUserCommandMap;
|
||||||
|
|
||||||
MiniBuffer *m_miniBuffer = nullptr;
|
MiniBuffer *m_miniBuffer = nullptr;
|
||||||
FakeVimPluginRunData *runData = nullptr;
|
|
||||||
|
|
||||||
QString m_lastHighlight;
|
QString m_lastHighlight;
|
||||||
|
|
||||||
@@ -870,6 +867,8 @@ private:
|
|||||||
QString m_needle;
|
QString m_needle;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static FakeVimCompletionAssistProvider theFakeVimCompletionAssistProvider;
|
||||||
|
|
||||||
class FakeVimAssistProposalItem final : public AssistProposalItem
|
class FakeVimAssistProposalItem final : public AssistProposalItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -967,17 +966,7 @@ IAssistProcessor *FakeVimCompletionAssistProvider::createProcessor(const AssistI
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
// FakeVimUserCommandsModel
|
||||||
//
|
|
||||||
// FakeVimPluginRunData
|
|
||||||
//
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
class FakeVimPluginRunData
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
FakeVimCompletionAssistProvider wordProvider;
|
|
||||||
};
|
|
||||||
|
|
||||||
QVariant FakeVimUserCommandsModel::data(const QModelIndex &index, int role) const
|
QVariant FakeVimUserCommandsModel::data(const QModelIndex &index, int role) const
|
||||||
{
|
{
|
||||||
@@ -1028,7 +1017,6 @@ FakeVimPluginPrivate::FakeVimPluginPrivate()
|
|||||||
|
|
||||||
void FakeVimPluginPrivate::initialize()
|
void FakeVimPluginPrivate::initialize()
|
||||||
{
|
{
|
||||||
runData = new FakeVimPluginRunData;
|
|
||||||
/*
|
/*
|
||||||
// Set completion settings and keep them up to date.
|
// Set completion settings and keep them up to date.
|
||||||
TextEditorSettings *textEditorSettings = TextEditorSettings::instance();
|
TextEditorSettings *textEditorSettings = TextEditorSettings::instance();
|
||||||
@@ -1591,7 +1579,7 @@ void FakeVimPluginPrivate::editorOpened(IEditor *editor)
|
|||||||
});
|
});
|
||||||
|
|
||||||
handler->simpleCompletionRequested.set([this, handler](const QString &needle, bool forward) {
|
handler->simpleCompletionRequested.set([this, handler](const QString &needle, bool forward) {
|
||||||
runData->wordProvider.setActive(needle, forward, handler);
|
theFakeVimCompletionAssistProvider.setActive(needle, forward, handler);
|
||||||
});
|
});
|
||||||
|
|
||||||
handler->windowCommandRequested.set([this, handler](const QString &map, int count) {
|
handler->windowCommandRequested.set([this, handler](const QString &map, int count) {
|
||||||
@@ -1726,7 +1714,7 @@ void FakeVimPluginPrivate::editorOpened(IEditor *editor)
|
|||||||
|
|
||||||
handler->completionRequested.set([this, tew] {
|
handler->completionRequested.set([this, tew] {
|
||||||
if (tew)
|
if (tew)
|
||||||
tew->invokeAssist(Completion, &runData->wordProvider);
|
tew->invokeAssist(Completion, &theFakeVimCompletionAssistProvider);
|
||||||
});
|
});
|
||||||
|
|
||||||
handler->processOutput.set([](const QString &command, const QString &input, QString *output) {
|
handler->processOutput.set([](const QString &command, const QString &input, QString *output) {
|
||||||
@@ -2037,9 +2025,6 @@ void FakeVimPlugin::initialize()
|
|||||||
|
|
||||||
ExtensionSystem::IPlugin::ShutdownFlag FakeVimPlugin::aboutToShutdown()
|
ExtensionSystem::IPlugin::ShutdownFlag FakeVimPlugin::aboutToShutdown()
|
||||||
{
|
{
|
||||||
delete dd->runData;
|
|
||||||
dd->runData = nullptr;
|
|
||||||
|
|
||||||
StatusBarManager::destroyStatusBarWidget(dd->m_miniBuffer);
|
StatusBarManager::destroyStatusBarWidget(dd->m_miniBuffer);
|
||||||
dd->m_miniBuffer = nullptr;
|
dd->m_miniBuffer = nullptr;
|
||||||
return SynchronousShutdown;
|
return SynchronousShutdown;
|
||||||
|
|||||||
Reference in New Issue
Block a user