Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions client/utils/Table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ namespace snapper
size_t trim = -1;
};

size_t last_visible_idx = 0;

vector<ColumnVars> column_vars;
};

Expand Down Expand Up @@ -92,6 +94,12 @@ namespace snapper
calculate_widths(table, row, false, 0);

calculate_abbriviated_widths(table);

// calculate last visible idx

for (size_t idx = 0; idx < column_vars.size(); ++idx)
if (!column_vars[idx].hidden)
last_visible_idx = idx;
}


Expand Down Expand Up @@ -272,7 +280,7 @@ namespace snapper
column = output_info.trimmed(column, column_params[idx].align, output_info.column_vars[idx].trim);

bool first = idx == 0;
bool last = idx == output_info.column_vars.size() - 1;
bool last = idx == output_info.last_visible_idx;

size_t extra = (idx == tree_idx) ? 2 * lasts.size() : 0;

Expand Down Expand Up @@ -353,7 +361,7 @@ namespace snapper
for (size_t j = 0; j < output_info.column_vars[idx].width; ++j)
s << glyph(1);

if (idx == output_info.column_vars.size() - 1)
if (idx == output_info.last_visible_idx)
break;

s << glyph(1) << glyph(2) << glyph(1);
Expand Down
20 changes: 20 additions & 0 deletions testsuite/table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,23 @@ BOOST_AUTO_TEST_CASE(test7)

check(table, output);
}


BOOST_AUTO_TEST_CASE(test8)
{
Table table({ "A", "B", Cell("Number", Id::NUMBER, Align::RIGHT) });

table.set_style(Style::LIGHT);
table.set_visibility(Id::NUMBER, Visibility::AUTO);

Table::Row row1(table, { "a", "b", "" });
table.add(row1);

vector<string> output = {
"A │ B",
"──┼──",
"a │ b"
};

check(table, output);
}
Loading