Reverted minor changes to stream helper w.r.t checking if fill, lead and remainder are empty

This commit is contained in:
Pranav Srinivas Kumar
2020-05-24 22:47:18 -05:00
parent d0562438d5
commit 885748d4c2

View File

@@ -136,21 +136,18 @@ public:
std::ostream &write(float progress) { std::ostream &write(float progress) {
auto pos = static_cast<size_t>(progress * bar_width / 100.0); auto pos = static_cast<size_t>(progress * bar_width / 100.0);
for (size_t i = 0; i < bar_width;) { for (size_t i = 0, current_display_width = 0; i < bar_width;) {
std::string next{""}; std::string next;
size_t current_display_width = 0;
if (i < pos && !fill.empty()) { if (i < pos) {
next = fill; next = fill;
current_display_width = unicode::display_width(fill); current_display_width = unicode::display_width(fill);
} else if (i == pos && !lead.empty()) { } else if (i == pos) {
next = lead; next = lead;
current_display_width = unicode::display_width(lead); current_display_width = unicode::display_width(lead);
} else { } else {
if (!remainder.empty()) { next = remainder;
next = remainder; current_display_width = unicode::display_width(remainder);
current_display_width = unicode::display_width(remainder);
}
} }
i += current_display_width; i += current_display_width;
@@ -218,4 +215,4 @@ private:
}; };
} // namespace details } // namespace details
} // namespace indicators } // namespace indicators