Browse Source

fix: join_items_by_hovered

0xc3 4 weeks ago
parent
commit
d655418061
1 changed files with 16 additions and 12 deletions
  1. 16 12
      src/saura/cmd/sandbox/sandbox.cpp

+ 16 - 12
src/saura/cmd/sandbox/sandbox.cpp

@@ -250,23 +250,26 @@ struct SandboxApp : AppBase {
             auto join_items_by_hovered{[](const std::vector<Item> &items,
                                           size_t limit) -> std::string {
               std::ostringstream oss;
-              bool first = true;
+              uint32_t count_hovered = 0;
+
               for (size_t i = 0; i < items.size(); ++i) {
                 if (!items[i].is_hovered)
                   continue;
 
-                if (i == limit) {
-                  if (!first)
-                    oss << ", ";
-                  oss << "...";
-                  break;
-                }
+                count_hovered += 1;
 
-                if (!first)
-                  oss << ", ";
+                if (count_hovered == 1) {
+                  oss << items[i].name;
+                  continue;
+                }
 
-                oss << items[i].name;
-                first = false;
+                if (count_hovered > 1) {
+                  if (count_hovered > limit) {
+                    oss << ", ...";
+                    break;
+                  }
+                  oss << ", " << items[i].name;
+                }
               }
               return oss.str();
             }};
@@ -275,6 +278,7 @@ struct SandboxApp : AppBase {
                 {"Нет", false},
                 {"Физ", false},
                 {"Юр", false},
+                {"Контрагент", false},
             };
 
             static int current_item = 0;
@@ -313,7 +317,7 @@ struct SandboxApp : AppBase {
                 }
               }
 
-              title = join_items_by_hovered(items, 3);
+              title = join_items_by_hovered(items, 2);
 
               ImGui::EndCombo();
             }