LanguageClient: manually track document version

Using the document revision causes issues for some servers.

Task-number: QTCREATORBUG-25766
Change-Id: Ic858e19c6fe39e57c9d3124913887aafee0a3cd0
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2021-06-14 11:47:04 +02:00
parent 200723cf13
commit 439bb9c4ae
8 changed files with 35 additions and 23 deletions

View File

@@ -117,14 +117,13 @@ static QTextEdit::ExtraSelection toDiagnosticsSelections(const Diagnostic &diagn
return QTextEdit::ExtraSelection{cursor, fontSettings.toTextCharFormat(style)};
}
void DiagnosticManager::showDiagnostics(const DocumentUri &uri)
void DiagnosticManager::showDiagnostics(const DocumentUri &uri, int version)
{
const FilePath &filePath = uri.toFilePath();
if (TextDocument *doc = TextDocument::textDocumentForFilePath(filePath)) {
QList<QTextEdit::ExtraSelection> extraSelections;
const VersionedDiagnostics &versionedDiagnostics = m_diagnostics.value(uri);
const int docRevision = doc->document()->revision();
if (versionedDiagnostics.version.value_or(docRevision) == docRevision) {
if (versionedDiagnostics.version.value_or(version) == version) {
const auto icon = QIcon::fromTheme("edit-copy", Utils::Icons::COPY.icon());
const QString tooltip = tr("Copy to Clipboard");
for (const Diagnostic &diagnostic : versionedDiagnostics.diagnostics) {