Преглед изворни кода

fix(AI): join_items_by_hovered

0xc3 пре 4 недеља
родитељ
комит
a9fc5f2045
1 измењених фајлова са 6 додато и 1 уклоњено
  1. 6 1
      src/saura/cmd/sandbox/sandbox.cpp

+ 6 - 1
src/saura/cmd/sandbox/sandbox.cpp

@@ -250,18 +250,23 @@ struct SandboxApp : AppBase {
             auto join_items_by_hovered{[](const std::vector<Item> &items,
                                           size_t limit) -> std::string {
               std::ostringstream oss;
+              bool first = true;
               for (size_t i = 0; i < items.size(); ++i) {
                 if (!items[i].is_hovered)
                   continue;
 
                 if (i == limit) {
+                  if (!first)
+                    oss << ", ";
                   oss << "...";
                   break;
                 }
-                if (i > 0)
+
+                if (!first)
                   oss << ", ";
 
                 oss << items[i].name;
+                first = false;
               }
               return oss.str();
             }};