forked from qt-creator/qt-creator
clangd: update current document filter after initialize
This makes sure that the lsp filter gets enabled if a document is opened before the corresponding clangd server was initialized. This happens when loading a session with an open document. Change-Id: I7987ea60c6fca8b5c070af3a7bcd5325667ed0c5 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
|
||||
#include "clangcompletioncontextanalyzer.h"
|
||||
#include "clangconstants.h"
|
||||
#include "clangdlocatorfilters.h"
|
||||
#include "clangdqpropertyhighlighter.h"
|
||||
#include "clangmodelmanagersupport.h"
|
||||
#include "clangpreprocessorassistproposalitem.h"
|
||||
@@ -1558,6 +1559,9 @@ ClangdClient::ClangdClient(Project *project, const Utils::FilePath &jsonDbDir)
|
||||
});
|
||||
|
||||
connect(this, &Client::initialized, this, [this] {
|
||||
auto currentDocumentFilter = static_cast<ClangdCurrentDocumentFilter *>(
|
||||
CppEditor::CppModelManager::instance()->currentDocumentFilter());
|
||||
currentDocumentFilter->updateCurrentClient();
|
||||
// If we get this signal while there are pending searches, it means that
|
||||
// the client was re-initialized, i.e. clangd crashed.
|
||||
|
||||
|
@@ -287,6 +287,11 @@ ClangdCurrentDocumentFilter::ClangdCurrentDocumentFilter() : d(new Private)
|
||||
|
||||
ClangdCurrentDocumentFilter::~ClangdCurrentDocumentFilter() { delete d; }
|
||||
|
||||
void ClangdCurrentDocumentFilter::updateCurrentClient()
|
||||
{
|
||||
d->lspFilter.updateCurrentClient();
|
||||
}
|
||||
|
||||
void ClangdCurrentDocumentFilter::prepareSearch(const QString &entry)
|
||||
{
|
||||
const auto doc = TextEditor::TextDocument::currentTextDocument();
|
||||
|
@@ -66,6 +66,8 @@ public:
|
||||
ClangdCurrentDocumentFilter();
|
||||
~ClangdCurrentDocumentFilter() override;
|
||||
|
||||
void updateCurrentClient();
|
||||
|
||||
private:
|
||||
void prepareSearch(const QString &entry) override;
|
||||
QList<Core::LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future,
|
||||
|
Reference in New Issue
Block a user