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);


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);
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to