diff --git a/src/libs/languageserverprotocol/progresssupport.h b/src/libs/languageserverprotocol/progresssupport.h index 0c2be91cda4..65cead4287b 100644 --- a/src/libs/languageserverprotocol/progresssupport.h +++ b/src/libs/languageserverprotocol/progresssupport.h @@ -76,8 +76,12 @@ public: * The value should be steadily rising. Clients are free to ignore values * that are not following this rule. */ - Utils::optional percentage() const { return optionalValue(percentageKey); } - void setPercentage(int percentage) { insert(percentageKey, percentage); } + + // Allthough percentage is defined as an uint by the protocol some server + // return a double here. Be less strict and also use a double. + // CAUTION: the range is still 0 - 100 and not 0 - 1 + Utils::optional percentage() const { return optionalValue(percentageKey); } + void setPercentage(double percentage) { insert(percentageKey, percentage); } void clearPercentage() { remove(percentageKey); } }; diff --git a/src/plugins/languageclient/progressmanager.cpp b/src/plugins/languageclient/progressmanager.cpp index a8543378334..d25da8a3e0f 100644 --- a/src/plugins/languageclient/progressmanager.cpp +++ b/src/plugins/languageclient/progressmanager.cpp @@ -107,9 +107,8 @@ void ProgressManager::reportProgress(const ProgressToken &token, } } if (progress.futureInterface) { - const Utils::optional &progressValue = report.percentage(); - if (progressValue.has_value()) - progress.futureInterface->setProgressValue(*progressValue); + if (const Utils::optional &percentage = report.percentage(); percentage.has_value()) + progress.futureInterface->setProgressValue(*percentage); } }