LanguageClient: update outline after document

Do not react on documents contents changes, but postpone the document
symbol request after these document changes were send to the server.

Change-Id: I43ec8f832c6a1fa6471146a5ec6e3e9223b02c91
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
David Schulz
2021-07-07 07:42:47 +02:00
parent e8e32894cc
commit ed199da1df

View File

@@ -283,7 +283,7 @@ private:
void updateModel(const DocumentUri &resultUri, const DocumentSymbolsResult &result);
void updateEntry();
void activateEntry();
void requestSymbols();
void documentUpdated(TextEditor::TextDocument *document);
LanguageClientOutlineModel m_model;
QPointer<Client> m_client;
@@ -318,13 +318,12 @@ OutlineComboBox::OutlineComboBox(Client *client, TextEditor::BaseTextEditor *edi
connect(client->documentSymbolCache(), &DocumentSymbolCache::gotSymbols,
this, &OutlineComboBox::updateModel);
connect(editor->textDocument(), &TextEditor::TextDocument::contentsChanged,
this, &OutlineComboBox::requestSymbols);
connect(client, &Client::documentUpdated, this, &OutlineComboBox::documentUpdated);
connect(m_editorWidget, &TextEditor::TextEditorWidget::cursorPositionChanged,
this, &OutlineComboBox::updateEntry);
connect(this, QOverload<int>::of(&QComboBox::activated), this, &OutlineComboBox::activateEntry);
requestSymbols();
documentUpdated(editor->textDocument());
}
void OutlineComboBox::updateModel(const DocumentUri &resultUri, const DocumentSymbolsResult &result)
@@ -365,9 +364,9 @@ void OutlineComboBox::activateEntry()
}
}
void OutlineComboBox::requestSymbols()
void OutlineComboBox::documentUpdated(TextEditor::TextDocument *document)
{
if (m_client)
if (document == m_editorWidget->textDocument())
m_client->documentSymbolCache()->requestSymbols(m_uri);
}