Skip to content

Commit

Permalink
- avoid exception when failing to set abbreviate flag
Browse files Browse the repository at this point in the history
  • Loading branch information
aschnell committed Mar 7, 2024
1 parent 2166d24 commit e8d30a2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
11 changes: 11 additions & 0 deletions client/utils/Table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 2 additions & 0 deletions client/utils/Table.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
3 changes: 2 additions & 1 deletion client/utils/TableFormatter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit e8d30a2

Please sign in to comment.