[PATCH] D75604: [clangd] Round WorkDoneProgressBegin.percentage down

Kirill Bobyrev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 4 06:11:29 PST 2020


kbobyrev created this revision.
kbobyrev added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, MaskRay, ilya-biryukov.
Herald added a project: clang.
kbobyrev updated this revision to Diff 248164.
kbobyrev added a comment.

%s/ceil/floor/g


When showing job progression in the text editors, it is hard to read
"precise" percentage numbers. This patch rounds
WorkDoneProgressBegin.percentage to 2 decimal places to improve readability.
While plugins might have different heuristics on how to display those numbers,
many of them will just show the value server provided and therefore it's easier
to do "formatting" on our side.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75604

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp


Index: clang-tools-extra/clangd/ClangdLSPServer.cpp
===================================================================
--- clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -1406,6 +1406,8 @@
       WorkDoneProgressReport Report;
       Report.percentage = 100.0 * (Stats.Completed - Stats.LastIdle) /
                           (Stats.Enqueued - Stats.LastIdle);
+      // Round down to 2 decimal places for readability.
+      Report.percentage = std::floor(*Report.percentage * 100.0) / 100.0;
       Report.message =
           llvm::formatv("{0}/{1}", Stats.Completed - Stats.LastIdle,
                         Stats.Enqueued - Stats.LastIdle);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75604.248164.patch
Type: text/x-patch
Size: 698 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200304/24912cc9/attachment.bin>


More information about the cfe-commits mailing list