]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- avoid exception when failing to set abbreviate flag 881/head
authorArvin Schnell <aschnell@suse.de>
Thu, 7 Mar 2024 07:41:46 +0000 (08:41 +0100)
committerArvin Schnell <aschnell@suse.de>
Thu, 7 Mar 2024 07:43:58 +0000 (08:43 +0100)
client/utils/Table.cc
client/utils/Table.h
client/utils/TableFormatter.cc

index 4056e3f8cb6b900260cf41a508b66ea2e735e98c..81e1293c2b280f78977a9d0bb9a32b46f54d1436 100644 (file)
@@ -262,6 +262,17 @@ namespace snapper
     }
 
 
+    bool
+    Table::has_id(Id id) const
+    {
+       for (size_t i = 0; i < ids.size(); ++i)
+           if (ids[i] == id)
+               return true;
+
+       return false;
+    }
+
+
     size_t
     Table::id_to_index(Id id) const
     {
index 308ce3bd991fd959977a362b5db06b003b00edaf..cc97e6ea923a218eae9ed3dbe12098666c91d125 100644 (file)
@@ -141,6 +141,8 @@ namespace snapper
 
        const vector<Row> get_rows() const { return rows; }
 
+       bool has_id(Id id) const;
+
        void set_show_header(bool show_header) { Table::show_header = show_header; }
        void set_show_grid(bool show_grid) { Table::show_grid = show_grid; }
        void set_style(Style style) { Table::style = style; }
index b2141ff15d8297dc213f90aeee69252922a2d8cb..435d28f1cefcd0ddb9ffe4c98992c50a343c0686 100644 (file)
@@ -37,7 +37,8 @@ namespace snapper
        table.set_style(table_formatter.style);
 
        for (Id id : table_formatter._abbrev)
-           table.set_abbreviate(id, true);
+           if (table.has_id(id))
+               table.set_abbreviate(id, true);
 
        for (const vector<string>& row : table_formatter._rows)
        {