[bottom_status] fix out-of-bounds when with word-wrap

Related to #1058
This commit is contained in:
Tim Stack 2022-09-16 11:20:15 -07:00
parent bfa8ae2c42
commit 116b40f28c
2 changed files with 11 additions and 16 deletions

View File

@ -69,21 +69,16 @@ bottom_status_source::update_line_number(listview_curses* lc)
sf.set_value(" L%'d", (int) lc->get_top());
}
if (lc->get_inner_height() > 0) {
std::vector<attr_line_t> rows(1);
lc->get_data_source()->listview_value_for_rows(
*lc, lc->get_top(), rows);
const auto& sa = rows[0].get_attrs();
auto error_wrapper = get_string_attr(sa, SA_ERROR);
if (error_wrapper) {
this->bss_line_error.set_value(error_wrapper.value().get());
} else {
this->bss_line_error.clear();
}
} else {
this->bss_line_error.clear();
}
this->bss_line_error.set_value(
lc->map_top_row([](const attr_line_t& top_row)
-> nonstd::optional<std::string> {
const auto& sa = top_row.get_attrs();
auto error_wrapper = get_string_attr(sa, SA_ERROR);
if (error_wrapper) {
return error_wrapper.value().get();
}
return nonstd::nullopt;
}).value_or(""));
}
void

View File

@ -244,7 +244,7 @@ public:
auto map_top_row(F func) ->
typename std::result_of<F(const attr_line_t&)>::type
{
if (this->get_inner_height() == 0) {
if (this->lv_top >= this->get_inner_height()) {
return nonstd::nullopt;
}